Reconstruct active formatting elements when <math> or <svg> start#724
Merged
simonwuelker merged 1 commit intoservo:mainfrom Jan 25, 2026
Conversation
As per 13.2.6.4.7 The "in body" insertion mode: A start tag whose tag name is "math" [Reconstruct the active formatting elements](https://html.spec.whatwg.org/multipage/parsing.html#reconstruct-the-active-formatting-elements), if any. [Adjust MathML attributes](https://html.spec.whatwg.org/multipage/parsing.html#adjust-mathml-attributes) for the token. (This fixes the case of MathML attributes that are not all lowercase.) [Adjust foreign attributes](https://html.spec.whatwg.org/multipage/parsing.html#adjust-foreign-attributes) for the token. (This fixes the use of namespaced attributes, in particular XLink.) [Insert a foreign element](https://html.spec.whatwg.org/multipage/parsing.html#insert-a-foreign-element) for the token, with [MathML namespace](https://infra.spec.whatwg.org/#mathml-namespace) and false. If the token has its *[self-closing flag](https://html.spec.whatwg.org/multipage/parsing.html#self-closing-flag)* set, pop the [current node](https://html.spec.whatwg.org/multipage/parsing.html#current-node) off the [stack of open elements](https://html.spec.whatwg.org/multipage/parsing.html#stack-of-open-elements) and [acknowledge the token's *self-closing flag*](https://html.spec.whatwg.org/multipage/parsing.html#acknowledge-self-closing-flag). A start tag whose tag name is "svg" [Reconstruct the active formatting elements](https://html.spec.whatwg.org/multipage/parsing.html#reconstruct-the-active-formatting-elements), if any. [Adjust SVG attributes](https://html.spec.whatwg.org/multipage/parsing.html#adjust-svg-attributes) for the token. (This fixes the case of SVG attributes that are not all lowercase.) [Adjust foreign attributes](https://html.spec.whatwg.org/multipage/parsing.html#adjust-foreign-attributes) for the token. (This fixes the use of namespaced attributes, in particular XLink in SVG.) [Insert a foreign element](https://html.spec.whatwg.org/multipage/parsing.html#insert-a-foreign-element) for the token, with [SVG namespace](https://infra.spec.whatwg.org/#svg-namespace) and false. If the token has its *[self-closing flag](https://html.spec.whatwg.org/multipage/parsing.html#self-closing-flag)* set, pop the [current node](https://html.spec.whatwg.org/multipage/parsing.html#current-node) off the [stack of open elements](https://html.spec.whatwg.org/multipage/parsing.html#stack-of-open-elements) and [acknowledge the token's *self-closing flag*](https://html.spec.whatwg.org/multipage/parsing.html#acknowledge-self-closing-flag).
4135713 to
07924e8
Compare
simonwuelker
approved these changes
Jan 25, 2026
Contributor
simonwuelker
left a comment
There was a problem hiding this comment.
There might be more coming, let me know if you're interested in them or not!
We absolutely are, thank you!
fasterthanlime
added a commit
to bearcove/hotmeal
that referenced
this pull request
Jan 25, 2026
Resolves #27 - the vendored html5ever has been replaced with a git dependency on servo/html5ever main branch. Key changes: - Remove vendor/html5ever directory entirely - Update Cargo.toml to use git deps for html5ever, markup5ever, tendril - Fix test that incorrectly expected body to NOT receive attributes from stray <body> tags (the spec says to merge them, and browsers do too) The upstream html5ever now includes the math/svg active formatting elements reconstruction fix (servo/html5ever#724), which makes it match browser behavior for cases like <li><u><li><svg>. Investigation notes: - The original patch to avoid merging body attrs was incorrect - HTML5 spec section 13.2.6.4.7 explicitly says to add missing attrs - Browser fuzzing confirmed Chrome adds attrs from stray body tags - The vendored html5ever had no other hotmeal-specific patches needed
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.
As per 13.2.6.4.7 The "in body" insertion mode.
Found via fuzzing in https://github.com/bearcove/hotmeal (one of the fuzz targets compare DOM trees as parsed by Blink and html5ever).
There might be more coming, let me know if you're interested in them or not!