wip: fix transform order

This commit is contained in:
Evan You 2019-09-23 07:57:56 -04:00
parent bb8524e199
commit b04be6a561
4 changed files with 6 additions and 9 deletions

View File

@ -318,7 +318,9 @@ function genIfBranch(
if (condition) {
// v-if or v-else-if
const { push, indent, deindent, newline } = context
push(`(${condition.content})`, condition)
push(`(`)
genExpression(condition, context)
push(`)`)
indent()
context.indentLevel++
push(`? `)

View File

@ -21,9 +21,9 @@ export function compile(
transform(ast, {
...options,
nodeTransforms: [
...(!__BROWSER__ && options.useWith === false ? [rewriteExpression] : []),
transformIf,
transformFor,
...(!__BROWSER__ && options.useWith === false ? [rewriteExpression] : []),
prepareElementForCodegen,
...(options.nodeTransforms || []) // user transforms
],

View File

@ -31,9 +31,6 @@ export const rewriteExpression: NodeTransform = (node, context) => {
}
}
}
} else if (node.type === NodeTypes.IF) {
for (let i = 0; i < node.branches.length; i++) {}
} else if (node.type === NodeTypes.FOR) {
}
}
@ -102,10 +99,7 @@ function convertExpression(
})
return {
type: NodeTypes.EXPRESSION,
content: '',
isStatic: false,
loc: node.loc,
...node,
children
}
}

View File

@ -17,6 +17,7 @@ export const transformFor = createStructuralDirectiveTransform(
if (aliases) {
// TODO inject identifiers to context
// and remove on exit
context.replaceNode({
type: NodeTypes.FOR,
loc: node.loc,