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

🐛 fix(react): allow to use polyfills to parse html #1514

Merged
merged 2 commits into from
Oct 25, 2024

Conversation

dackmin
Copy link
Member

@dackmin dackmin commented Oct 25, 2024

DOMParser is a client-side DOM level 1 class that doesn't exist in a server side environment. This creates hydratation errors as the sanitized html would be '' on the server, but the right value on the client.
To prevent this, I added the ability to pass spec-compatible DOMParser & XMLSerializer polyfills to the builder (for example @xmldom/xmldom can be used on both client & server), and adapted the code a bit to not use querySelector that was not implemented in most of the xml-compatible parsers.

Copy link

vercel bot commented Oct 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
oak ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 25, 2024 0:26am

@dackmin dackmin merged commit b69ca97 into master Oct 25, 2024
6 checks passed
@dackmin dackmin deleted the fix/sanitize-html-ssr-error branch October 25, 2024 13:23
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

Successfully merging this pull request may close these issues.

2 participants