Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lit-html] Re-rendering an asyncReplace clears its value. #4408

Closed
sorvell opened this issue Nov 20, 2023 · 1 comment · Fixed by #4409
Closed

[lit-html] Re-rendering an asyncReplace clears its value. #4408

sorvell opened this issue Nov 20, 2023 · 1 comment · Fixed by #4409

Comments

@sorvell
Copy link
Member

sorvell commented Nov 20, 2023

Which package(s) are affected?

Lit Core (lit / lit-html / lit-element / reactive-element)

Description

When a template using an asyncReplace is re-rendered without changing the iterable or its current value in the asyncReplace, the value is incorrectly cleared.

Reproduction

https://lit.dev/playground/#gist=257917d929b16bd6f3109c81f121b992

Click the requestUpdate button

Expected: the asyncReplace value should not change
Actual: the asyncReplace value is cleared (it is replaced if the iterable emits another value)

Workaround

None.

Is this a regression?

No or unsure. This never worked, or I haven't tried before.

Affected versions

3.x

Browser/OS/Node environment

All

@sorvell
Copy link
Member Author

sorvell commented Nov 20, 2023

The issue appears to be that this line needs to return noChange.

sorvell pushed a commit to sorvell/lit that referenced this issue Nov 20, 2023
AndrewJakubowicz added a commit that referenced this issue Nov 21, 2023
…#4409)

* async-replace correctly re-renders when value is
unchanged. Fixes #4408.

* Update packages/lit-html/src/test/directives/async-replace_test.ts

Co-authored-by: Andrew Jakubowicz <spyr1014@gmail.com>

* Update packages/lit-html/src/test/directives/async-replace_test.ts

---------

Co-authored-by: Andrew Jakubowicz <spyr1014@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant