LibWeb: Parse HTML fragments directly into DocumentFragment#10567
Merged
shannonbooth merged 4 commits intoJul 10, 2026
Conversation
shannonbooth
force-pushed
the
fragment-parser-confusion
branch
2 times, most recently
from
July 9, 2026 19:54
0d19e99 to
81ccdc0
Compare
|
Your pull request has conflicts that need to be resolved before it can be reviewed and merged. Make sure to rebase your branch on top of the latest |
The spec version of this function does not take an insertion point.
shannonbooth
force-pushed
the
fragment-parser-confusion
branch
from
July 10, 2026 18:44
81ccdc0 to
fc23bfb
Compare
Member
Author
|
fixed da conflicts |
shannonbooth
force-pushed
the
fragment-parser-confusion
branch
from
July 10, 2026 19:08
fc23bfb to
880c24c
Compare
Refactor the HTML fragment parser to insert the root's children straight into a DocumentFragment instead of a connected temporary document. On top of being a correctness fix, this should also improve performance of fragment parsing. Making this change has other fallout due to the timing of document adoption changing. This results in related other changes needing to be made, including: * The parser having "allow declarative shadow roots" as a parser flag so that it does not read the flag from the wrong document. This prevents some regressions which would happen otherwise, but also aligns our behaviour in general where in some cases the wrong setting was previously being chosen. * Custom element registry is now taken from the *target* node instead of the *context* node. This also prevents regressions as part of the fallout of these changes, but also fixes the selection of the custom element registry for ShadowRoots (which was previously being taken from the root document). * Use a null custom element registry for template.innerHTML. Similar to both cases above, this prevents regressions from the above changes due to the change in timing of document adoption, but fixing this also aligns behaviour closer what other engines implement. Ref: whatwg/html#12624
shannonbooth
force-pushed
the
fragment-parser-confusion
branch
from
July 10, 2026 19:13
880c24c to
c61632e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactor the HTML fragment parser to insert the root's children straight
into a DocumentFragment instead of a connected temporary document. On
top of being a correctness fix, this should also improve performance of
fragment parsing.
Making this change has other fallout due to the timing of document
adoption changing. This results in related other changes needing to be
made, including:
so that it does not read the flag from the wrong document. This
prevents some regressions which would happen otherwise, but also
aligns our behaviour in general where in some cases the wrong setting
was previously being chosen.
of the context node. This also prevents regressions as part of the
fallout of these changes, but also fixes the selection of the custom
element registry for ShadowRoots (which was previously being taken
from the root document).
both cases above, this prevents regressions from the above changes
due to the change in timing of document adoption, but fixing this
also aligns behaviour closer what other engines implement.
See: whatwg/html#12624 for background.