From 452a65c98a9354bb529185638475b72d8ca19543 Mon Sep 17 00:00:00 2001 From: Evan You Date: Wed, 29 Nov 2017 15:48:28 -0500 Subject: [PATCH] feat(weex): pass stateless component test case --- .../weex/compiler/modules/recycle-list/component-root.js | 1 + test/weex/cases/recycle-list/components/stateless.vdom.js | 8 ++++---- test/weex/helpers/index.js | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/platforms/weex/compiler/modules/recycle-list/component-root.js b/src/platforms/weex/compiler/modules/recycle-list/component-root.js index 41360786e48..cc8325c9922 100644 --- a/src/platforms/weex/compiler/modules/recycle-list/component-root.js +++ b/src/platforms/weex/compiler/modules/recycle-list/component-root.js @@ -10,5 +10,6 @@ export function postTransformComponentRoot ( if (!el.parent) { // component root addAttr(el, '@isComponentRoot', 'true') + addAttr(el, '@componentProps', JSON.stringify({})) } } diff --git a/test/weex/cases/recycle-list/components/stateless.vdom.js b/test/weex/cases/recycle-list/components/stateless.vdom.js index 06afdbf572a..ac8c641e143 100644 --- a/test/weex/cases/recycle-list/components/stateless.vdom.js +++ b/test/weex/cases/recycle-list/components/stateless.vdom.js @@ -13,11 +13,11 @@ attr: { templateType: 'A' }, children: [{ type: 'div', + attr: { + '@isComponentRoot': true, + '@componentProps': {} + }, // not supported yet - // attr: { - // '@isComponentRoot': true, - // '@componentProps': {} - // }, // style: { // height: '120px', // justifyContent: 'center', diff --git a/test/weex/helpers/index.js b/test/weex/helpers/index.js index 9f85091501e..1f46616ec8f 100644 --- a/test/weex/helpers/index.js +++ b/test/weex/helpers/index.js @@ -114,7 +114,7 @@ function omitUseless (object) { if (isObject(object)) { delete object.ref for (const key in object) { - if (isEmptyObject(object[key]) || object[key] === undefined) { + if (key.charAt(0) !== '@' && (isEmptyObject(object[key]) || object[key] === undefined)) { delete object[key] } omitUseless(object[key])