Просмотр исходного кода

feat(weex): pass stateless component test case

Evan You 8 лет назад
Родитель
Сommit
452a65c98a

+ 1 - 0
src/platforms/weex/compiler/modules/recycle-list/component-root.js

@@ -10,5 +10,6 @@ export function postTransformComponentRoot (
   if (!el.parent) {
   if (!el.parent) {
     // component root
     // component root
     addAttr(el, '@isComponentRoot', 'true')
     addAttr(el, '@isComponentRoot', 'true')
+    addAttr(el, '@componentProps', JSON.stringify({}))
   }
   }
 }
 }

+ 4 - 4
test/weex/cases/recycle-list/components/stateless.vdom.js

@@ -13,11 +13,11 @@
     attr: { templateType: 'A' },
     attr: { templateType: 'A' },
     children: [{
     children: [{
       type: 'div',
       type: 'div',
+      attr: {
+        '@isComponentRoot': true,
+        '@componentProps': {}
+      },
       // not supported yet
       // not supported yet
-      // attr: {
-      //   '@isComponentRoot': true,
-      //   '@componentProps': {}
-      // },
       // style: {
       // style: {
       //   height: '120px',
       //   height: '120px',
       //   justifyContent: 'center',
       //   justifyContent: 'center',

+ 1 - 1
test/weex/helpers/index.js

@@ -114,7 +114,7 @@ function omitUseless (object) {
   if (isObject(object)) {
   if (isObject(object)) {
     delete object.ref
     delete object.ref
     for (const key in object) {
     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]
         delete object[key]
       }
       }
       omitUseless(object[key])
       omitUseless(object[key])