refactor(compiler): flush transform onExit in reverse
This commit is contained in:
parent
e8ee163fdd
commit
0615cf0108
@ -33,7 +33,7 @@ function parseWithElementTransform(
|
|||||||
// block as root node
|
// block as root node
|
||||||
const ast = parse(`<div>${template}</div>`, options)
|
const ast = parse(`<div>${template}</div>`, options)
|
||||||
transform(ast, {
|
transform(ast, {
|
||||||
nodeTransforms: [optimizeText, transformElement],
|
nodeTransforms: [transformElement, optimizeText],
|
||||||
...options
|
...options
|
||||||
})
|
})
|
||||||
const codegenNode = (ast as any).children[0].children[0]
|
const codegenNode = (ast as any).children[0].children[0]
|
||||||
|
@ -52,9 +52,9 @@ export function baseCompile(
|
|||||||
]
|
]
|
||||||
: []),
|
: []),
|
||||||
trackSlotScopes,
|
trackSlotScopes,
|
||||||
optimizeText,
|
|
||||||
transformSlotOutlet,
|
transformSlotOutlet,
|
||||||
transformElement,
|
transformElement,
|
||||||
|
optimizeText,
|
||||||
...(options.nodeTransforms || []) // user transforms
|
...(options.nodeTransforms || []) // user transforms
|
||||||
],
|
],
|
||||||
directiveTransforms: {
|
directiveTransforms: {
|
||||||
|
@ -346,7 +346,8 @@ export function traverseNode(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// exit transforms
|
// exit transforms
|
||||||
for (let i = 0; i < exitFns.length; i++) {
|
let i = exitFns.length
|
||||||
|
while (i--) {
|
||||||
exitFns[i]()
|
exitFns[i]()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ export function buildSlots(
|
|||||||
// since it likely uses a scope variable.
|
// since it likely uses a scope variable.
|
||||||
// TODO: This can be further optimized to only make it dynamic when the slot
|
// TODO: This can be further optimized to only make it dynamic when the slot
|
||||||
// actually uses the scope variables.
|
// actually uses the scope variables.
|
||||||
let hasDynamicSlots = context.scopes.vSlot > 0 || context.scopes.vFor > 0
|
let hasDynamicSlots = context.scopes.vSlot > 1 || context.scopes.vFor > 0
|
||||||
|
|
||||||
// 1. Check for default slot with slotProps on component itself.
|
// 1. Check for default slot with slotProps on component itself.
|
||||||
// <Comp v-slot="{ prop }"/>
|
// <Comp v-slot="{ prop }"/>
|
||||||
|
Loading…
Reference in New Issue
Block a user