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
Given this element that benefits from DOM Diffing since it would require multiple DOM manipulations to update the element when the heading attribute changes:
One thing to note is that this assumes that the template will only ever be used with a Custom Element and not the Shadow DOM. A user needs to define a second Custom element in order to use the Shadow DOM with a different instance as the style tag needs to remain in the template to apply to the Shadow root.
The way the DOM diffing works is that we call the Element function when attributes or store keys are updated and then compare the returned HTML string to the currently rendered Element in the page.
In the case where the heading attribute is updated to "nope" the element function containing slots from above will be rendered as:
So the diff will fail on the slot to button comparison leaving you with nothing rendered in the place of the slot.
There is no good way currently to determine what the content of the slot should be since the original markup has been mixed with the template contents and slot replacement.
We could add a property of initialMarkup that in this case would contain the <button>Enter</button> markup and then use that to expand the slots in the browser during the render.
We move the code that removes the style and script tags into their own functions in order to reuse them as this.removeStylesTags() during rerender and before DOM diffing.
Open to other suggestions.
The text was updated successfully, but these errors were encountered:
The problem
Given this element that benefits from DOM Diffing since it would require multiple DOM manipulations to update the element when the
heading
attribute changes:The unnamed slot allows any content to be set as children used as such:
Initial SSR does the correct thing and expands the custom element correctly giving you:
The issue arrises when you update the heading attribute and the DOM diffing happens.
The template written into the page looks like this:
The way the DOM diffing works is that we call the Element function when attributes or store keys are updated and then compare the returned HTML string to the currently rendered Element in the page.
In the case where the
heading
attribute is updated to "nope" the element function containing slots from above will be rendered as:and the existing markup will be
So the diff will fail on the
slot
tobutton
comparison leaving you with nothing rendered in the place of theslot
.There is no good way currently to determine what the content of the slot should be since the original markup has been mixed with the template contents and slot replacement.
Expected result
Actual result
Some ideas:
initialMarkup
that in this case would contain the<button>Enter</button>
markup and then use that to expand the slots in the browser during the render.this.removeStylesTags()
during rerender and before DOM diffing.The text was updated successfully, but these errors were encountered: