You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a continuation of #11497. It seems that lazy loading still breaks in some uncertain conditions. In particular, the images load eagerly when the <img> is wrapped in a logic block ({#if}, {#each}, maybe others) and there's a sibling element next to the block, such as the div in my repro, or the entire block is wrapped in another element.
<divstyle="height: 3000px; background: black;"></div>
<!-- Also doesn't work in {#each} blocks. -->
{#iftrue}
<imgheight="200"width="200"loading="lazy"src="https://picsum.photos/seed/{Math.random()}/200">
{/if}
Also I tried to test out the simple case (no logic blocks) in a local SvelteKit project and it seems to load eagerly despite correctly lazy-loading in REPL. (I disabled SSR if it makes a difference.) Here's the reproduction repo and equivalent Svelte 5 REPL
@trueadm I remember you said that you had to give comment nodes the importNode treatment aswell because of reasons - is it maybe that if a parent that isn't inserted yet, and that is not using importNode, is then introducing that bug to all its children that are added to it, regardless of whether or not their elements where created using importNode or not? If this is true, does that mean we should just ditch the cloneNode logic altogether and always use importNode?
Describe the bug
This is a continuation of #11497. It seems that lazy loading still breaks in some uncertain conditions. In particular, the images load eagerly when the
<img>
is wrapped in a logic block ({#if}
,{#each}
, maybe others) and there's a sibling element next to the block, such as the div in my repro, or the entire block is wrapped in another element.Originally posted by @yamplum in #11545 (comment)
cc @trueadm
Reproduction
Svelte 4 REPL
Svelte 5 REPL
Alternatively:
Svelte 4 REPL
Svelte 5 REPL
Logs
No response
System Info
Severity
blocking an upgrade
The text was updated successfully, but these errors were encountered: