diff --git a/packages/compiler-core/__tests__/transforms/transformElement.spec.ts b/packages/compiler-core/__tests__/transforms/transformElement.spec.ts index fb6230ae..092cb56d 100644 --- a/packages/compiler-core/__tests__/transforms/transformElement.spec.ts +++ b/packages/compiler-core/__tests__/transforms/transformElement.spec.ts @@ -33,7 +33,7 @@ function parseWithElementTransform( // block as root node const ast = parse(`
${template}
`, options) transform(ast, { - nodeTransforms: [optimizeText, transformElement], + nodeTransforms: [transformElement, optimizeText], ...options }) const codegenNode = (ast as any).children[0].children[0] diff --git a/packages/compiler-core/src/index.ts b/packages/compiler-core/src/index.ts index 35624b10..336659a6 100644 --- a/packages/compiler-core/src/index.ts +++ b/packages/compiler-core/src/index.ts @@ -52,9 +52,9 @@ export function baseCompile( ] : []), trackSlotScopes, - optimizeText, transformSlotOutlet, transformElement, + optimizeText, ...(options.nodeTransforms || []) // user transforms ], directiveTransforms: { diff --git a/packages/compiler-core/src/transform.ts b/packages/compiler-core/src/transform.ts index 1fe68d5d..6970eb1c 100644 --- a/packages/compiler-core/src/transform.ts +++ b/packages/compiler-core/src/transform.ts @@ -346,7 +346,8 @@ export function traverseNode( } // exit transforms - for (let i = 0; i < exitFns.length; i++) { + let i = exitFns.length + while (i--) { exitFns[i]() } } diff --git a/packages/compiler-core/src/transforms/vSlot.ts b/packages/compiler-core/src/transforms/vSlot.ts index 64b407b1..7bb044e1 100644 --- a/packages/compiler-core/src/transforms/vSlot.ts +++ b/packages/compiler-core/src/transforms/vSlot.ts @@ -110,7 +110,7 @@ export function buildSlots( // since it likely uses a scope variable. // TODO: This can be further optimized to only make it dynamic when the slot // 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. //