diff --git a/flow/compiler.js b/flow/compiler.js index 81e1c6eb..cc356979 100644 --- a/flow/compiler.js +++ b/flow/compiler.js @@ -37,9 +37,12 @@ declare type CompiledResult = { }; declare type ModuleOptions = { + // transform an AST node before any attributes are processed // returning an ASTElement from pre/transforms replaces the element preTransformNode: (el: ASTElement) => ?ASTElement; + // transform an AST node after built-ins like v-if, v-for are processed transformNode: (el: ASTElement) => ?ASTElement; + // transform an AST node after its children have been processed // cannot return replacement in postTransform because tree is already finalized postTransformNode: (el: ASTElement) => void; genData: (el: ASTElement) => string; // generate extra data string for an element diff --git a/src/compiler/parser/index.js b/src/compiler/parser/index.js index a2476dbb..851db1c6 100644 --- a/src/compiler/parser/index.js +++ b/src/compiler/parser/index.js @@ -221,10 +221,6 @@ export function parse ( } else { endPre(element) } - // apply post-transforms - for (let i = 0; i < postTransforms.length; i++) { - postTransforms[i](element, options) - } }, end () { @@ -238,6 +234,11 @@ export function parse ( stack.length -= 1 currentParent = stack[stack.length - 1] endPre(element) + + // apply post-transforms + for (let i = 0; i < postTransforms.length; i++) { + postTransforms[i](element, options) + } }, chars (text: string) {