Skip to content

Conversation

simonihmig
Copy link
Owner

@simonihmig simonihmig commented Sep 25, 2025

<img> element is reused across renders, when no LQIP is used. Otherwise DOM recreation is enforced to wipe out the state of the previously loaded image.

Fixes #1583, in particular #1583 (comment).

Added a rerender test case where this was missing, and added assertions for DOM reuse (default) or DOM recreation (LQIP).

@changeset-bot
Copy link

changeset-bot bot commented Sep 25, 2025

🦋 Changeset detected

Latest commit: c97ca84

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@responsive-image/svelte Patch
@responsive-image/ember Patch
@responsive-image/react Patch
@responsive-image/solid Patch
@responsive-image/wc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@simonihmig simonihmig force-pushed the fix-lqip-recreate-img branch from 5410462 to 5dba5c7 Compare October 6, 2025 20:39
@simonihmig simonihmig requested a review from wkillerud October 6, 2025 20:45
@simonihmig
Copy link
Owner Author

@wkillerud completed the PR to cover all frameworks, if you want to give this another review!

It's not looking quite beautiful in all cases, React and Ember needed some shenanigans, for the rest it was rather straightforward as they had explicit support for the concept of key/keyed, even for a single element. But it works everywhere it seems, without any manual DOM manipulation workarounds.

Other use case for recreating DOM elements was mentioned btw: forcing new animations/transitions. See https://lit.dev/docs/templates/directives/#keyed and https://svelte.dev/docs/svelte/key.

@simonihmig simonihmig marked this pull request as ready for review October 6, 2025 20:54
@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 6, 2025

Copy link
Collaborator

@wkillerud wkillerud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work digging into all of these frameworks! 🎉 Looks good to me 👍

@simonihmig simonihmig merged commit f4eee7b into main Oct 7, 2025
5 checks passed
@simonihmig simonihmig deleted the fix-lqip-recreate-img branch October 7, 2025 20:58
@github-actions github-actions bot mentioned this pull request Oct 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LQIP not updated when src changes

2 participants