]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
wip: fix transform order
authorEvan You <yyx990803@gmail.com>
Mon, 23 Sep 2019 11:57:56 +0000 (07:57 -0400)
committerEvan You <yyx990803@gmail.com>
Mon, 23 Sep 2019 17:29:52 +0000 (13:29 -0400)
packages/compiler-core/src/codegen.ts
packages/compiler-core/src/index.ts
packages/compiler-core/src/transforms/expression.ts
packages/compiler-core/src/transforms/vFor.ts

index 820b1d97162a7cbf4fe52c5b6e9591b31d388347..f66245adfa4ec87d53eec559ea746c0acdbe2ab4 100644 (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(`? `)
index 5af9df1944b1e115c5ac37e0959f1fbc891b5ffb..a3a3e7117e9b7b41202de89443049aab04e74b5b 100644 (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
     ],
index 943cb5ace28a9658da146e8a3785553460291f0b..d365091ab871c109a2515d4a00384ebfdb28f798 100644 (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
   }
 }
index 8c293ea996e71066ac806aada90e650e56d8639a..ed42fa698152ec20733df9bc55d75ca64527ed1b 100644 (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,