Skip to content

Commit

Permalink
* [html5] fix the conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanks10100 committed Nov 4, 2016
1 parent 17b98c8 commit ac84559
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
4 changes: 2 additions & 2 deletions dist/weex-js-framework/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "weex-js-framework",
"version": "0.17.0-alpha2",
"version": "0.16.18",
"subversion": {
"framework": "0.17.0-alpha2",
"framework": "0.16.18",
"transformer": ">=0.1.5 <0.4"
},
"description": "Weex JS Framework",
Expand Down
26 changes: 25 additions & 1 deletion html5/frameworks/legacy/api/methods.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
/**
* @fileOverview The api for invoking with "$" prefix
*/
import config from '../config'

const {
nativeComponentMap
} = config

/**
* ==========================================================
Expand All @@ -23,6 +28,25 @@ export function $ (id) {
}
}

function addComponentMethods (app, el) {
if (el && el.type) {
const component = nativeComponentMap[el.type]
if (component && component.methods) {
component.methods.forEach((method) => {
el[method] = (...args) => {
app.callTasks({
component: component.type,
ref: el.ref,
method: method,
args: args
})
}
})
}
}
return el
}

/**
* find the element by id
* Note: there is only one id in whole component
Expand All @@ -32,7 +56,7 @@ export function $ (id) {
export function $el (id) {
const info = this._ids[id]
if (info) {
return info.el
return addComponentMethods(info.vm._app || {}, info.el)
}
}

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
"copy": "npm run copy:js && npm run copy:examples"
},
"subversion": {
"browser": "0.4.0",
"framework": "0.17.0-alpha2",
"browser": "0.5.0",
"framework": "0.16.18",
"transformer": ">=0.1.5 <0.4"
},
"dependencies": {
Expand Down

0 comments on commit ac84559

Please sign in to comment.