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
If you have a component that contains elements with self closing tags and they have properties on them, hydration on them causes uncaught errors. It seems <!--lit-node x--> assumes the element it's intended for is its parent and not possibly its sibling in the case of self closing tags. The self closing tag may not be wrapped in another element, although I don't suppose the parent element in this case would be correct anyways.
Create a web component with an element with self closing tags (eg, an img tag) on the root level (so not wrapped in <div> tags, for example). Give the element a lit property.
Call hydration on the component on the client side, or use the experimental-hydrate-support version.
Element is hydrated on the browser side with no console errors.
Actual Results
There is a console error.
Uncaught (in promise) TypeError: Cannot read properties of null (reading 'hasAttribute')
at hydrate (chunk-C2YYUDQW.js?v=532bb5dc:50:18)
at MyElement.LitElement.update (lit_experimental-hydrate-support_js.js?v=5fe040d7:44:7)
at MyElement.performUpdate (lit.js?v=5fe040d7:434:14)
at MyElement.scheduleUpdate (lit.js?v=5fe040d7:398:17)
at MyElement.__enqueueUpdate (lit.js?v=5fe040d7:391:25)
Browsers Affected
[ ]x Chrome
[ x] Firefox
[x ] Edge
The text was updated successfully, but these errors were encountered:
Description
If you have a component that contains elements with self closing tags and they have properties on them, hydration on them causes uncaught errors. It seems
<!--lit-node x-->
assumes the element it's intended for is its parent and not possibly its sibling in the case of self closing tags. The self closing tag may not be wrapped in another element, although I don't suppose the parent element in this case would be correct anyways.Here's the offending line of code: https://github.com/lit/lit/blob/main/packages/lit-html/src/experimental-hydrate.ts#L161
Steps to Reproduce
Create a web component with an element with self closing tags (eg, an img tag) on the root level (so not wrapped in
<div>
tags, for example). Give the element a lit property.Call hydration on the component on the client side, or use the experimental-hydrate-support version.
There's now an error in the console.
Live Reproduction Link
Stackblitz example
Expected Results
Element is hydrated on the browser side with no console errors.
Actual Results
There is a console error.
Browsers Affected
The text was updated successfully, but these errors were encountered: