Skip to content

Commit

Permalink
put path on analysis.elements instead of metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Nov 21, 2024
1 parent 8f02f1e commit c0c7ab8
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
3 changes: 1 addition & 2 deletions packages/svelte/src/compiler/phases/1-parse/state/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,7 @@ export default function element(parser) {
svg: false,
mathml: false,
scoped: false,
has_spread: false,
path: []
has_spread: false
},
parent: null
}
Expand Down
5 changes: 3 additions & 2 deletions packages/svelte/src/compiler/phases/2-analyze/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <textarea> into a value attribute if they are dynamic
if (node.name === 'textarea' && node.fragment.nodes.length > 0) {
Expand Down
1 change: 0 additions & 1 deletion packages/svelte/src/compiler/types/template.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ export namespace AST {
/** `true` if contains a SpreadAttribute */
has_spread: boolean;
scoped: boolean;
path: SvelteNode[];
};
}

Expand Down

0 comments on commit c0c7ab8

Please sign in to comment.