diff --git a/packages/frontend/lib/vite-plugin-create-search-index.ts b/packages/frontend/lib/vite-plugin-create-search-index.ts index 19b95a798e..a0a98b2d3e 100644 --- a/packages/frontend/lib/vite-plugin-create-search-index.ts +++ b/packages/frontend/lib/vite-plugin-create-search-index.ts @@ -100,14 +100,15 @@ type WalkVueNode = RootNode | TemplateChildNode | SimpleExpressionNode; */ function walkVueElements(nodes: WalkVueNode[], context: C, callback: (node: ElementNode, context: C) => C | undefined | void | false): void { for (const node of nodes) { + let currentContext = context; if (node.type === NodeTypes.COMPOUND_EXPRESSION) throw new Error("Unexpected COMPOUND_EXPRESSION"); if (node.type === NodeTypes.ELEMENT) { const result = callback(node, context); if (result === false) return; - if (result !== undefined) context = result; + if (result !== undefined) currentContext = result; } if ('children' in node) { - walkVueElements(node.children, context, callback); + walkVueElements(node.children, currentContext, callback); } } }