Use direct element reference when updating render container #5047
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This was still generating some console errors under some circumstances when an html-block was relatively quickly rendered and then updated again in quick succession. Here's what I think is happening: Before our async renderers can act, Lit is wiping out the value of the ref during its re-render. This leads to NREs in various places, since our renderers also do a bunch of asnyc things, so this can cause failures in a number of places.
While I could do something like
const renderContainer = this._renderContainerRef.value
to snag a direct reference to the element instead, I also think that throws away basically all of the value of using theref
directive anyways. 🤷Let me know if you would find it preferable for me to switch to the above, but for now I think it makes more sense to just use a
querySelector
.