Skip to content

Commit abf850e

Browse files
Reconstruct active formatting elements when <math> or <svg> start (#724)
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).
1 parent 9279dd2 commit abf850e

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

html5ever/src/tree_builder/rules.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -967,9 +967,15 @@ where
967967
ProcessResult::Done
968968
},
969969

970-
Token::Tag(tag @ tag!(<math>)) => self.enter_foreign(tag, ns!(mathml)),
970+
Token::Tag(tag @ tag!(<math>)) => {
971+
self.reconstruct_active_formatting_elements();
972+
self.enter_foreign(tag, ns!(mathml))
973+
},
971974

972-
Token::Tag(tag @ tag!(<svg>)) => self.enter_foreign(tag, ns!(svg)),
975+
Token::Tag(tag @ tag!(<svg>)) => {
976+
self.reconstruct_active_formatting_elements();
977+
self.enter_foreign(tag, ns!(svg))
978+
},
973979

974980
Token::Tag(
975981
tag!(<caption> | <col> | <colgroup> | <frame> | <head> |

0 commit comments

Comments
 (0)