From c0c7ab8bd10a812e84b267352b2afced4057e6d6 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 21 Nov 2024 15:28:51 -0500 Subject: [PATCH] put path on analysis.elements instead of metadata --- packages/svelte/src/compiler/phases/1-parse/state/element.js | 3 +-- packages/svelte/src/compiler/phases/2-analyze/index.js | 5 +++-- .../src/compiler/phases/2-analyze/visitors/RegularElement.js | 4 +--- packages/svelte/src/compiler/types/template.d.ts | 1 - 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/packages/svelte/src/compiler/phases/1-parse/state/element.js b/packages/svelte/src/compiler/phases/1-parse/state/element.js index 9082b76c49..f3c723783b 100644 --- a/packages/svelte/src/compiler/phases/1-parse/state/element.js +++ b/packages/svelte/src/compiler/phases/1-parse/state/element.js @@ -151,8 +151,7 @@ export default function element(parser) { svg: false, mathml: false, scoped: false, - has_spread: false, - path: [] + has_spread: false }, parent: null } diff --git a/packages/svelte/src/compiler/phases/2-analyze/index.js b/packages/svelte/src/compiler/phases/2-analyze/index.js index 7e69096010..168e5294bc 100644 --- a/packages/svelte/src/compiler/phases/2-analyze/index.js +++ b/packages/svelte/src/compiler/phases/2-analyze/index.js @@ -724,7 +724,7 @@ export function analyze_component(root, source, options) { warn_unused(analysis.css.ast); } - outer: for (const { node } of analysis.elements) { + outer: for (const { node, path } of analysis.elements) { if (node.type === 'RenderTag') continue; if (node.metadata.scoped) { @@ -780,8 +780,9 @@ export function analyze_component(root, source, options) { } ]) ); + if (is_custom_element_node(node) && node.attributes.length === 1) { - mark_subtree_dynamic(node.metadata.path); + mark_subtree_dynamic(path); } } } diff --git a/packages/svelte/src/compiler/phases/2-analyze/visitors/RegularElement.js b/packages/svelte/src/compiler/phases/2-analyze/visitors/RegularElement.js index af54f18035..faf447a302 100644 --- a/packages/svelte/src/compiler/phases/2-analyze/visitors/RegularElement.js +++ b/packages/svelte/src/compiler/phases/2-analyze/visitors/RegularElement.js @@ -22,9 +22,7 @@ export function RegularElement(node, context) { check_element(node, context); - node.metadata.path = [...context.path]; - - context.state.analysis.elements.push({ node, path: context.path }); + context.state.analysis.elements.push({ node, path: [...context.path] }); // Special case: Move the children of