popeindustries / lit

Fast server-rendering and client-hydration of lit-html templates and web components
MIT License
33 stars 4 forks source link

Improve hydration error message when unexpected `TemplateResult` was rendered to part #41

Closed ingvilddev closed 5 days ago

ingvilddev commented 1 week ago

Fixes https://github.com/popeindustries/lit/issues/35

Maybe this is a very bad and naive suggestion on how this should be implemented, but I wondered if what is suggested in this PR is good enough 🤓

We are anyhow in need in our app to be able to better locate which (child) node that resulted in the hydration error.

What this PR includes

PR changes explained

I debugged where the error was thrown and where the error was caught. It was not an obvious variable in either places that contained the information about which HTML element that caused it. The current implementation was the best place I could find it 🤓 Maybe it is a bad suggestion.

Before & After

Should not change functionality, since it is just a console.error(...) message that is changes.

Before

image

After

image
changeset-bot[bot] commented 1 week ago

🦋 Changeset detected

Latest commit: 6fcb80ce7914d828ef628586e05e2f532d240542

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages | Name | Type | | ------------------------------- | ----- | | @popeindustries/lit-html | Patch | | @popeindustries/lit-element | Patch | | @popeindustries/lit-html-server | Patch | | @popeindustries/lit | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR