fix: mark subtree dynamic for img with loading attribute (#14317)

* fix: mark subtree dynamic for img with loading attribute

* chore: unify conditions

* chore: change conditions
pull/14304/head
Paolo Ricciuti 4 days ago committed by GitHub
parent efc65d4e0c
commit 1f0700f5c5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: mark subtree dynamic for img with loading attribute

@ -18,9 +18,14 @@ export function Attribute(node, context) {
const parent = /** @type {SvelteNode} */ (context.path.at(-1)); const parent = /** @type {SvelteNode} */ (context.path.at(-1));
// special case if (parent.type === 'RegularElement') {
if (node.name === 'value') { // special case <option value="" />
if (parent.type === 'RegularElement' && parent.name === 'option') { if (node.name === 'value' && parent.name === 'option') {
mark_subtree_dynamic(context.path);
}
// special case <img loading="lazy" />
if (node.name === 'loading' && parent.name === 'img') {
mark_subtree_dynamic(context.path); mark_subtree_dynamic(context.path);
} }
} }

@ -1,7 +1,7 @@
import "svelte/internal/disclose-version"; import "svelte/internal/disclose-version";
import * as $ from "svelte/internal/client"; import * as $ from "svelte/internal/client";
var root = $.template(`<header><nav><a href="/">Home</a> <a href="/away">Away</a></nav></header> <main><h1> </h1> <div class="static"><p>we don't need to traverse these nodes</p></div> <p>or</p> <p>these</p> <p>ones</p> <!> <p>these</p> <p>trailing</p> <p>nodes</p> <p>can</p> <p>be</p> <p>completely</p> <p>ignored</p></main> <cant-skip><custom-elements></custom-elements></cant-skip> <div><input></div> <div><source></div> <select><option>a</option></select> <img src="..." alt="" loading="lazy">`, 3); var root = $.template(`<header><nav><a href="/">Home</a> <a href="/away">Away</a></nav></header> <main><h1> </h1> <div class="static"><p>we don't need to traverse these nodes</p></div> <p>or</p> <p>these</p> <p>ones</p> <!> <p>these</p> <p>trailing</p> <p>nodes</p> <p>can</p> <p>be</p> <p>completely</p> <p>ignored</p></main> <cant-skip><custom-elements></custom-elements></cant-skip> <div><input></div> <div><source></div> <select><option>a</option></select> <img src="..." alt="" loading="lazy"> <div><img src="..." alt="" loading="lazy"></div>`, 3);
export default function Skip_static_subtree($$anchor, $$props) { export default function Skip_static_subtree($$anchor, $$props) {
var fragment = root(); var fragment = root();
@ -42,8 +42,12 @@ export default function Skip_static_subtree($$anchor, $$props) {
$.reset(select); $.reset(select);
var img = $.sibling(select, 2); var img = $.sibling(select, 2);
var div_2 = $.sibling(img, 2);
var img_1 = $.child(div_2);
$.reset(div_2);
$.template_effect(() => $.set_text(text, $$props.title)); $.template_effect(() => $.set_text(text, $$props.title));
$.handle_lazy_img(img); $.handle_lazy_img(img);
$.handle_lazy_img(img_1);
$.append($$anchor, fragment); $.append($$anchor, fragment);
} }

@ -3,5 +3,5 @@ import * as $ from "svelte/internal/server";
export default function Skip_static_subtree($$payload, $$props) { export default function Skip_static_subtree($$payload, $$props) {
let { title, content } = $$props; let { title, content } = $$props;
$$payload.out += `<header><nav><a href="/">Home</a> <a href="/away">Away</a></nav></header> <main><h1>${$.escape(title)}</h1> <div class="static"><p>we don't need to traverse these nodes</p></div> <p>or</p> <p>these</p> <p>ones</p> ${$.html(content)} <p>these</p> <p>trailing</p> <p>nodes</p> <p>can</p> <p>be</p> <p>completely</p> <p>ignored</p></main> <cant-skip><custom-elements with="attributes"></custom-elements></cant-skip> <div><input autofocus></div> <div><source muted></div> <select><option value="a">a</option></select> <img src="..." alt="" loading="lazy">`; $$payload.out += `<header><nav><a href="/">Home</a> <a href="/away">Away</a></nav></header> <main><h1>${$.escape(title)}</h1> <div class="static"><p>we don't need to traverse these nodes</p></div> <p>or</p> <p>these</p> <p>ones</p> ${$.html(content)} <p>these</p> <p>trailing</p> <p>nodes</p> <p>can</p> <p>be</p> <p>completely</p> <p>ignored</p></main> <cant-skip><custom-elements with="attributes"></custom-elements></cant-skip> <div><input autofocus></div> <div><source muted></div> <select><option value="a">a</option></select> <img src="..." alt="" loading="lazy"> <div><img src="..." alt="" loading="lazy"></div>`;
} }

@ -45,3 +45,6 @@
</select> </select>
<img src="..." alt="" loading="lazy" /> <img src="..." alt="" loading="lazy" />
<div>
<img src="..." alt="" loading="lazy" />
</div>
Loading…
Cancel
Save