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

Commit70b97ac

Browse files
committed
feat(weex): recycle-list support stateful child component
1 parent452a65c commit70b97ac

File tree

5 files changed

+40
-41
lines changed

5 files changed

+40
-41
lines changed

‎src/core/util/props.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ export function validateProp (
4545
observe(value)
4646
observerState.shouldConvert=prevShouldConvert
4747
}
48-
if(process.env.NODE_ENV!=='production'){
48+
if(
49+
process.env.NODE_ENV!=='production'&&
50+
// skip validation for weex recycle-list child component props
51+
!(__WEEX__&&isObject(value)&&('@binding'invalue))
52+
){
4953
assertProp(prop,key,value,vm,absent)
5054
}
5155
returnvalue

‎src/platforms/weex/compiler/modules/recycle-list/component-root.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ export function postTransformComponentRoot (
1010
if(!el.parent){
1111
// component root
1212
addAttr(el,'@isComponentRoot','true')
13-
addAttr(el,'@componentProps',JSON.stringify({}))
13+
addAttr(el,'@componentProps','$props || {}')
1414
}
1515
}

‎src/platforms/weex/runtime/recycle-list/render-component-template.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ export function isRecyclableComponent (vnode: VNodeWithData): boolean {
1212
}
1313

1414
exportfunctionrenderRecyclableComponentTemplate(vnode:MountedComponentVNode):VNode{
15-
// TODO:
16-
// adding@isComponentRoot /@componentProps to the root node
17-
1815
// $flow-disable-line
1916
deletevnode.data.attrs[RECYCLE_LIST_MARKER]
2017
constvm=createComponentInstanceForVnode(vnode)

‎test/weex/cases/cases.spec.js

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -84,41 +84,39 @@ describe('Usage', () => {
8484
}).catch(done.fail)
8585
})
8686

87-
//it('stateless component with props', done => {
88-
// compileWithDeps('recycle-list/components/stateless-with-props.vue', [{
89-
// name: 'poster',
90-
// path: 'recycle-list/components/poster.vue'
91-
// }]).then(code => {
92-
// const id = String(Date.now() * Math.random())
93-
// const instance = createInstance(id, code)
94-
// setTimeout(() => {
95-
// const target = readObject('recycle-list/components/stateless-with-props.vdom.js')
96-
// expect(getRoot(instance)).toEqual(target)
97-
// done()
98-
// }, 50)
99-
// }).catch(done.fail)
100-
//})
87+
it('stateless component with props',done=>{
88+
compileWithDeps('recycle-list/components/stateless-with-props.vue',[{
89+
name:'poster',
90+
path:'recycle-list/components/poster.vue'
91+
}]).then(code=>{
92+
constid=String(Date.now()*Math.random())
93+
constinstance=createInstance(id,code)
94+
setTimeout(()=>{
95+
consttarget=readObject('recycle-list/components/stateless-with-props.vdom.js')
96+
expect(getRoot(instance)).toEqual(target)
97+
done()
98+
},50)
99+
}).catch(done.fail)
100+
})
101101

102-
// it('stateful component', done => {
103-
// compileWithDeps('recycle-list/components/stateful.vue', [{
104-
// name: 'counter',
105-
// path: 'recycle-list/components/counter.vue'
106-
// }]).then(code => {
107-
// const id = String(Date.now() * Math.random())
108-
// const instance = createInstance(id, code)
109-
// setTimeout(() => {
110-
// const target = readObject('recycle-list/components/stateful.vdom.js')
111-
// expect(getRoot(instance)).toEqual(target)
112-
// const event = getEvents(instance)[0]
113-
// fireEvent(instance, event.ref, event.type, {})
114-
// setTimeout(() => {
115-
// // TODO: check render results
116-
// // expect(getRoot(instance)).toEqual(target)
117-
// done()
118-
// })
119-
// }, 50)
120-
// }).catch(done.fail)
121-
// })
102+
it('stateful component',done=>{
103+
compileWithDeps('recycle-list/components/stateful.vue',[{
104+
name:'counter',
105+
path:'recycle-list/components/counter.vue'
106+
}]).then(code=>{
107+
constid=String(Date.now()*Math.random())
108+
constinstance=createInstance(id,code)
109+
setTimeout(()=>{
110+
consttarget=readObject('recycle-list/components/stateful.vdom.js')
111+
expect(getRoot(instance)).toEqual(target)
112+
constevent=getEvents(instance)[0]
113+
fireEvent(instance,event.ref,event.type,{})
114+
setTimeout(()=>{
115+
expect(getRoot(instance)).toEqual(target)
116+
done()
117+
})
118+
},50)
119+
}).catch(done.fail)
120+
})
122121
})
123122
})
124-

‎test/weex/cases/recycle-list/components/poster.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<template>
1+
<template recyclable="true">
22
<div>
33
<imageclass="image":src="imageUrl"></image>
44
<textclass="title">{{title}}</text>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp