Skip to content

Commit

Permalink
feat(weex): WIP adjust component transform stage
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Dec 19, 2017
1 parent 88f3889 commit 62e47c9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -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')
}
}
6 changes: 3 additions & 3 deletions src/platforms/weex/compiler/modules/recycle-list/component.js
Original file line number Diff line number Diff line change
@@ -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')
}
}
10 changes: 6 additions & 4 deletions src/platforms/weex/compiler/modules/recycle-list/index.js
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/platforms/weex/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,' +
Expand Down

0 comments on commit 62e47c9

Please sign in to comment.