perf: treat `<img loading>` as a static element again (#18711)

Emits less code and skips two live DOM traversals per instance.

`is_static_element` treats `<img>` with a `loading` attribute as
non-static. That was added in #14237 so `RegularElement` could emit
`$.handle_lazy_img(node_id)`, which needed a reference to the element.
#15272 deleted `handle_lazy_img` (replaced by `importNode`) and removed
the call site, but left this check behind.


---------

Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
pull/18714/head
Mathias Picker 4 days ago committed by GitHub
parent 135f1ec004
commit 359413f512
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
perf: treat `<img loading>` as a static element again

@ -171,11 +171,6 @@ export function is_static_element(node) {
return false;
}
// We need to apply src and loading after appending the img to the DOM for lazy loading to work
if (node.name === 'img' && attribute.name === 'loading') {
return false;
}
if (attribute.value !== true && !is_text_attribute(attribute)) {
return false;
}

@ -40,10 +40,7 @@ export default function Skip_static_subtree($$anchor, $$props) {
option.value = option.__value = 'a';
$.reset(select);
var img = $.sibling(select, 2);
$.next(2);
$.next(4);
$.template_effect(() => $.set_text(text, $$props.title));
$.append($$anchor, fragment);
}
Loading…
Cancel
Save