diff --git a/packages/svelte/src/compiler/phases/2-analyze/visitors/Attribute.js b/packages/svelte/src/compiler/phases/2-analyze/visitors/Attribute.js index ec48414bf6..ca0ea55d1f 100644 --- a/packages/svelte/src/compiler/phases/2-analyze/visitors/Attribute.js +++ b/packages/svelte/src/compiler/phases/2-analyze/visitors/Attribute.js @@ -30,10 +30,6 @@ export function Attribute(node, context) { } } - if (node.name === 'autofocus' || node.name === 'muted') { - mark_subtree_dynamic(context.path); - } - if (node.name.startsWith('on')) { mark_subtree_dynamic(context.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 7d1c4aaeaa..60bd1dd0c5 100644 --- a/packages/svelte/src/compiler/phases/2-analyze/visitors/RegularElement.js +++ b/packages/svelte/src/compiler/phases/2-analyze/visitors/RegularElement.js @@ -75,6 +75,16 @@ export function RegularElement(node, context) { node.attributes.push(create_attribute('value', child.start, child.end, [child])); } + if ( + node.attributes.some( + (attribute) => + attribute.type === 'Attribute' && + (attribute.name === 'autofocus' || attribute.name === 'muted') + ) + ) { + mark_subtree_dynamic(context.path); + } + const binding = context.state.scope.get(node.name); if ( binding !== null &&