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

[reactive-element] [lit-next] Appended multiple times within the same microtask causes createRenderRoot get called each time #1679

Closed
TimLuq opened this issue Mar 18, 2021 · 2 comments
Assignees

Comments

@TimLuq
Copy link

TimLuq commented Mar 18, 2021

I accidentally stumbled upon this scenario just now. If appended to the DOM multiple times before performeUpdate() has been able to execute, createRenderRoot() will be called each time. This may be unexpected behavior for subclasses overriding createRenderRoot(). An effect of this is when adoptable stylesheets are not supported the style tags are also duplicated multiple times (otherwise the stylesheets are readopted).

I would assume this is unwanted behavior and is probably a vestigial check from a time when createRenderRoot() and firstUpdated(changed)/_$didUpdate(changed) may have had different tasks to perform.

https://github.com/Polymer/lit-html/blob/f0d683b071aad02c423e45ea0d3db8816259759b/packages/reactive-element/src/reactive-element.ts#L735-L739

I propose changing the condition from !this.hasUpdated to !this.renderRoot. I am open to creating a PR for this (or for any other solution that the maintainers may prefer).

@sorvell
Copy link
Member

sorvell commented Mar 18, 2021

Thanks for reporting this. This is just an oversight and and obvious bug. It should be a simple fix, thanks for the PR offer but we should be able to handle this quickly.

@sorvell
Copy link
Member

sorvell commented Mar 22, 2021

Fixed via #1686.

@sorvell sorvell closed this as completed Mar 22, 2021
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

No branches or pull requests

2 participants