we don't need to traverse these nodes
or
these
ones
these
trailing
nodes
can
be
completely
ignored
diff --git a/.changeset/rotten-turkeys-sniff.md b/.changeset/rotten-turkeys-sniff.md
new file mode 100644
index 0000000000..53fb5bd663
--- /dev/null
+++ b/.changeset/rotten-turkeys-sniff.md
@@ -0,0 +1,5 @@
+---
+'svelte': patch
+---
+
+fix: mark subtree dynamic for img with loading attribute
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 6931f873fb..ca0ea55d1f 100644
--- a/packages/svelte/src/compiler/phases/2-analyze/visitors/Attribute.js
+++ b/packages/svelte/src/compiler/phases/2-analyze/visitors/Attribute.js
@@ -18,9 +18,14 @@ export function Attribute(node, context) {
const parent = /** @type {SvelteNode} */ (context.path.at(-1));
- // special case
- if (node.name === 'value') {
- if (parent.type === 'RegularElement' && parent.name === 'option') {
+ if (parent.type === 'RegularElement') {
+ // special case
+ if (node.name === 'value' && parent.name === 'option') {
+ mark_subtree_dynamic(context.path);
+ }
+
+ // special case
+ if (node.name === 'loading' && parent.name === 'img') {
mark_subtree_dynamic(context.path);
}
}
diff --git a/packages/svelte/tests/snapshot/samples/skip-static-subtree/_expected/client/index.svelte.js b/packages/svelte/tests/snapshot/samples/skip-static-subtree/_expected/client/index.svelte.js
index ae79efef42..8dd7df82cf 100644
--- a/packages/svelte/tests/snapshot/samples/skip-static-subtree/_expected/client/index.svelte.js
+++ b/packages/svelte/tests/snapshot/samples/skip-static-subtree/_expected/client/index.svelte.js
@@ -1,7 +1,7 @@
import "svelte/internal/disclose-version";
import * as $ from "svelte/internal/client";
-var root = $.template(` we don't need to traverse these nodes or these ones these trailing nodes can be completely ignored
we don't need to traverse these nodes
or
these
ones
these
trailing
nodes
can
be
completely
ignored
we don't need to traverse these nodes
or
these
ones
${$.html(content)}these
trailing
nodes
can
be
completely
ignored
we don't need to traverse these nodes
or
these
ones
${$.html(content)}these
trailing
nodes
can
be
completely
ignored