Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
forked fromvuejs/vue

Commit0bf0cbe

Browse files
Hanks10100yyx990803
authored andcommitted
revert(weex): remove the "receiveTasks" api and support component hook (vuejs#7053)
1 parent0c11aa8 commit0bf0cbe

File tree

4 files changed

+14
-100
lines changed

4 files changed

+14
-100
lines changed

‎package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
"typescript":"^2.6.1",
126126
"uglify-js":"^3.0.15",
127127
"webpack":"^3.10.0",
128-
"weex-js-runtime":"^0.23.0",
128+
"weex-js-runtime":"^0.23.1",
129129
"weex-styler":"^0.3.0"
130130
},
131131
"config": {

‎src/platforms/weex/entry-framework.js

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -113,53 +113,6 @@ export function getRoot (instanceId) {
113113
returninstance.app.$el.toJSON()
114114
}
115115

116-
constjsHandlers={
117-
fireEvent:(id, ...args)=>{
118-
returnfireEvent(instances[id], ...args)
119-
},
120-
callback:(id, ...args)=>{
121-
returncallback(instances[id], ...args)
122-
}
123-
}
124-
125-
functionfireEvent(instance,nodeId,type,e,domChanges,params){
126-
constel=instance.document.getRef(nodeId)
127-
if(el){
128-
returninstance.document.fireEvent(el,type,e,domChanges,params)
129-
}
130-
returnnewError(`invalid element reference "${nodeId}"`)
131-
}
132-
133-
functioncallback(instance,callbackId,data,ifKeepAlive){
134-
constresult=instance.document.taskCenter.callback(callbackId,data,ifKeepAlive)
135-
instance.document.taskCenter.send('dom',{action:'updateFinish'},[])
136-
returnresult
137-
}
138-
139-
/**
140-
* Accept calls from native (event or callback).
141-
*
142-
*@param {string} id
143-
*@param {array} tasks list with `method` and `args`
144-
*/
145-
exportfunctionreceiveTasks(id,tasks){
146-
constinstance=instances[id]
147-
if(instance&&Array.isArray(tasks)){
148-
constresults=[]
149-
tasks.forEach((task)=>{
150-
consthandler=jsHandlers[task.method]
151-
constargs=[...task.args]
152-
/* istanbul ignore else */
153-
if(typeofhandler==='function'){
154-
args.unshift(id)
155-
results.push(handler(...args))
156-
}
157-
})
158-
returnresults
159-
}
160-
returnnewError(`invalid instance id "${id}" or tasks`)
161-
}
162-
163116
/**
164117
* Create a fresh instance of Vue for each Weex instance.
165118
*/

‎src/platforms/weex/util/index.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* globals document */
22

33
import{makeMap}from'shared/util'
4+
import{warn}from'core/util/index'
45

56
exportconstisReservedTag=makeMap(
67
'template,script,style,element,content,slot,link,meta,svg,view,'+
@@ -20,7 +21,7 @@ export const canBeLeftOpenTag = makeMap(
2021
)
2122

2223
exportconstisRuntimeComponent=makeMap(
23-
'richtext,trisition,trisition-group',
24+
'richtext,transition,transition-group',
2425
true
2526
)
2627

@@ -40,3 +41,14 @@ export function query (el, document) {
4041
document.documentElement.appendChild(placeholder)
4142
returnplaceholder
4243
}
44+
45+
exportfunctionregisterHook(cid,type,hook,fn){
46+
if(!document||!document.taskCenter){
47+
warn(`Can't find available "document" or "taskCenter".`)
48+
return
49+
}
50+
if(typeofdocument.taskCenter.registerHook==='function'){
51+
returndocument.taskCenter.registerHook(cid,type,hook,fn)
52+
}
53+
warn(`Not support to register component hook "${type}@${hook}#${cid}".`)
54+
}

‎test/weex/runtime/framework.spec.js

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -152,57 +152,6 @@ describe('framework APIs', () => {
152152
expect(root).toMatch(/notfound/)
153153
})
154154

155-
// TODO: deprecated, move to weex-js-runtime
156-
it('receiveTasks: fireEvent',(done)=>{
157-
constid=String(Date.now()*Math.random())
158-
constinstance=createInstance(id,`
159-
new Vue({
160-
data: {
161-
x: 'Hello'
162-
},
163-
methods: {
164-
update: function (e) {
165-
this.x = 'World'
166-
}
167-
},
168-
render: function (createElement) {
169-
return createElement('div', {}, [
170-
createElement('text', { attrs: { value: this.x }, on: { click: this.update }}, [])
171-
])
172-
},
173-
el: "body"
174-
})
175-
`)
176-
expect(getRoot(instance)).toEqual({
177-
type:'div',
178-
children:[{
179-
type:'text',
180-
attr:{value:'Hello'},
181-
event:['click']
182-
}]
183-
})
184-
consttextRef=framework.getRoot(id).children[0].ref
185-
framework.receiveTasks(id,[
186-
{method:'fireEvent',args:[textRef,'click']}
187-
])
188-
setTimeout(()=>{
189-
expect(getRoot(instance)).toEqual({
190-
type:'div',
191-
children:[{
192-
type:'text',
193-
attr:{value:'World'},
194-
event:['click']
195-
}]
196-
})
197-
framework.destroyInstance(id)
198-
constresult=framework.receiveTasks(id,[
199-
{method:'fireEvent',args:[textRef,'click']}
200-
])
201-
expect(resultinstanceofError).toBe(true)
202-
done()
203-
})
204-
})
205-
206155
it('vm.$getConfig',()=>{
207156
constid=String(Date.now()*Math.random())
208157
global.WXEnvironment={

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp