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 49a642eb49..dd8a594e61 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,14 @@ 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' + ) + ) { + mark_subtree_dynamic(context.path); + } + const binding = context.state.scope.get(node.name); if ( binding !== null && diff --git a/packages/svelte/tests/runtime-legacy/samples/autofocus-2/main.svelte b/packages/svelte/tests/runtime-legacy/samples/autofocus-2/main.svelte index 2487e00da6..e3ea9a76d4 100644 --- a/packages/svelte/tests/runtime-legacy/samples/autofocus-2/main.svelte +++ b/packages/svelte/tests/runtime-legacy/samples/autofocus-2/main.svelte @@ -1,6 +1,2 @@