Sfoglia il codice sorgente

feat(weex): WIP adjust component transform stage

Evan You 8 anni fa
parent
commit
62e47c9eb4

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

@@ -1,14 +1,14 @@
 /* @flow */
 
-import { addRawAttr } from 'compiler/helpers'
+import { addAttr } from 'compiler/helpers'
 
 // mark component root nodes as
-export function preTransformComponentRoot (
+export function postTransformComponentRoot (
   el: ASTElement,
   options: WeexCompilerOptions
 ) {
   if (!el.parent) {
     // component root
-    addRawAttr(el, '$isComponentRoot', true)
+    addAttr(el, '@isComponentRoot', 'true')
   }
 }

+ 3 - 3
src/platforms/weex/compiler/modules/recycle-list/component.js

@@ -1,16 +1,16 @@
 /* @flow */
 
-import { addRawAttr } from 'compiler/helpers'
+import { addAttr } from 'compiler/helpers'
 import { RECYCLE_LIST_MARKER } from 'weex/util/index'
 
 // mark components as inside recycle-list so that we know we need to invoke
 // their special @render function instead of render in create-component.js
-export function preTransformComponent (
+export function postTransformComponent (
   el: ASTElement,
   options: WeexCompilerOptions
 ) {
   // $flow-disable-line (we know isReservedTag is there)
   if (!options.isReservedTag(el.tag) && el.tag !== 'cell-slot') {
-    addRawAttr(el, RECYCLE_LIST_MARKER, 'true')
+    addAttr(el, RECYCLE_LIST_MARKER, 'true')
   }
 }

+ 6 - 4
src/platforms/weex/compiler/modules/recycle-list/index.js

@@ -1,7 +1,7 @@
 /* @flow */
 
-import { preTransformComponent } from './component'
-import { preTransformComponentRoot } from './component-root'
+import { postTransformComponent } from './component'
+import { postTransformComponentRoot } from './component-root'
 import { postTransformText } from './text'
 import { preTransformVBind } from './v-bind'
 import { preTransformVIf } from './v-if'
@@ -20,8 +20,6 @@ function preTransformNode (el: ASTElement, options: WeexCompilerOptions) {
     currentRecycleList = el
   }
   if (shouldCompile(el, options)) {
-    preTransformComponent(el, options)
-    preTransformComponentRoot(el, options)
     preTransformVBind(el, options)
     preTransformVIf(el, options) // also v-else-if and v-else
     preTransformVFor(el, options)
@@ -36,6 +34,10 @@ function transformNode (el: ASTElement, options: WeexCompilerOptions) {
 
 function postTransformNode (el: ASTElement, options: WeexCompilerOptions) {
   if (shouldCompile(el, options)) {
+    // mark child component in parent template
+    postTransformComponent(el, options)
+    // mark root in child component template
+    postTransformComponentRoot(el, options)
     // <text>: transform children text into value attr
     if (el.tag === 'text') {
       postTransformText(el, options)

+ 1 - 1
src/platforms/weex/util/index.js

@@ -4,7 +4,7 @@ declare var document: Object;
 import { makeMap } from 'shared/util'
 import { warn } from 'core/util/index'
 
-export const RECYCLE_LIST_MARKER = '$inRecycleList'
+export const RECYCLE_LIST_MARKER = '@inRecycleList'
 
 export const isReservedTag = makeMap(
   'template,script,style,element,content,slot,link,meta,svg,view,' +