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

Update parseHTML to use Document.parseHTMLUnsafe where supported #3185

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

lukewarlow
Copy link

Description

Updates parseHTML to use Document.parseHTMLUnsafe where supported

This allows HTMX to support declarative shadow dom

Corresponding issue: #2682

Testing

Please explain how you tested this change manually, and, if applicable, what new tests you added. If
you're making a change to just the website, you can omit this section.

Checklist

  • I have read the contribution guidelines
  • I have targeted this PR against the correct branch (master for website changes, dev for
    source changes)
  • This is either a bugfix, a documentation update, or a new feature that has been explicitly
    approved via an issue
  • I ran the test suite locally (npm run test) and verified that it succeeded

@lukewarlow
Copy link
Author

Not sure how best to test this?

@lukewarlow
Copy link
Author

You can compare specs at https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring and https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-parsehtmlunsafe

These should be identical behaviour wise, except perhaps for the URL setting of the resultant document but I don't believe that's an issue for HTMX's use case.

@lukewarlow
Copy link
Author

cleanInnerHtmlForHistory it'll be interesting to see if this might need updating, currently it returns innerHTML which serialises in a way that won't include declarative shadow dom. It might be that we need to swap that for getHTML()

@Telroshan Telroshan added the enhancement New feature or request label Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants