Skip to content

Commit

Permalink
Merge branch 'html5-feature-0.4' into html5-feature-0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanks10100 committed Nov 11, 2016
2 parents dd037cf + aecf46a commit aff35de
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
39 changes: 32 additions & 7 deletions html5/render/browser/bridge/receiver.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,20 @@ function processCallQueue () {
}

function processCall (instanceId, call) {
const isComponent = typeof call.module === 'undefined'
isComponent ? componentCall(instanceId, call) : moduleCall(instanceId, call)

const callbackId = call.callbackId
if ((callbackId
|| callbackId === 0
|| callbackId === '0')
&& callbackId !== '-1'
&& callbackId !== -1) {
performNextTick(instanceId, callbackId)
}
}

function moduleCall (instanceId, call) {
const moduleName = call.module
const methodName = call.method
let module, method
Expand All @@ -82,15 +96,26 @@ function processCall (instanceId, call) {
}

method.apply(global.weex.getInstance(instanceId), args)
}

const callbackId = call.callbackId
if ((callbackId
|| callbackId === 0
|| callbackId === '0')
&& callbackId !== '-1'
&& callbackId !== -1) {
performNextTick(instanceId, callbackId)
function componentCall (instanceId, call) {
const componentName = call.component
const ref = call.ref
const methodName = call.method
const args = call.args || call.arguments || []

const elem = global.weex.getInstance(instanceId).getComponentManager().getComponent(ref)
if (!elem) {
return console.error(`[h5-render] component of ref ${ref} doesn't exist.`)
}

let method

if (!(method = elem[methodName])) {
return console.error(`[h5-render] component ${componentName} doesn't have a method named ${methodName}.`)
}

method.apply(elem, args)
}

function performNextTick (instanceId, callbackId) {
Expand Down
8 changes: 8 additions & 0 deletions html5/render/browser/extend/components/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ const proto = {
node.classList.add('weex-element')
this.placeholder && (node.placeholder = this.placeholder)
return node
},

focus () {
this.node.focus()
},

blur () {
this.node.blur()
}
}

Expand Down
4 changes: 4 additions & 0 deletions html5/render/browser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ Weex.install(droot)

Weex.install(extensions)

global.registerComponents([
{ type: 'input', methods: ['focus', 'blur'] }
])

export default Weex

0 comments on commit aff35de

Please sign in to comment.