fix: consider img with loading attribute not static (#14237)

* fix: consider img with loading attribute not static

* chore: add comment for `is_static_element`

* chore: better comment

Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>

---------

Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
pull/14253/head
Paolo Ricciuti 10 months ago committed by GitHub
parent 1e5a385c96
commit d207666ec3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: consider img with loading attribute not static

@ -150,6 +150,11 @@ function is_static_element(node) {
return false; 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 (node.name.includes('-')) { if (node.name.includes('-')) {
return false; // we're setting all attributes on custom elements through properties return false; // we're setting all attributes on custom elements through properties
} }

@ -0,0 +1,5 @@
import { test } from '../../test';
export default test({
html: `<h1></h1><img src="..." loading="lazy" />`
});
Loading…
Cancel
Save