Skip to content

Commit

Permalink
HTML parser: make breaking out of foreign content apply in innerHTML
Browse files Browse the repository at this point in the history
This is intended to match Chromium and WebKit.

Fixes #5117.
  • Loading branch information
zcorpan authored and domenic committed Mar 2, 2021
1 parent fade69e commit f690ad9
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -111073,23 +111073,12 @@ document.body.appendChild(text);
<dd>
<p><span>Parse error</span>.</p>

<!-- for sanity's sake, we limit this wacked quirk to legacy full-document parsing, not to
innerHTML. We have no data showing whether (or that) this is needed for innerHTML. If innerHTML
is used on an SVG or MathML node, it definitely doesn't make any sense (there's nothing to pop
to in the first place). Therefore, rather than trying to figure out in what convoluted
conditions we could actually do this quirk for innerHTML, we just don't do it at all. -->
<p>While the <span>current node</span> is not a <span>MathML text integration point</span>, an
<span>HTML integration point</span>, or an element in the <span>HTML namespace</span>, pop
elements from the <span>stack of open elements</span>.</p>

<p>If the parser was created as part of the <span>HTML fragment parsing algorithm</span>, then
act as described in the "any other start tag" entry below. (<span>fragment case</span>)</p>

<p>Otherwise:</p>

<p>Pop an element from the <span>stack of open elements</span>, and then keep popping more
elements from the <span>stack of open elements</span> until the <span>current node</span> is a
<span>MathML text integration point</span>, an <span>HTML integration point</span>, or an
element in the <span>HTML namespace</span>.</p>

<p>Then, reprocess the token.</p>
<p>Process the token <span>using the rules for</span> the "<span data-x="insertion mode:
in body">in body</span>" <span>insertion mode</span>.</p>
</dd>

<dt>Any other start tag</dt>
Expand Down

3 comments on commit f690ad9

@TRowbotham
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm seeing 2 test failures with this change; in particular, the change to use the "in body insertion mode" directly, instead of reprocessing with the current insertion mode. In both cases[1][2], we lose out on foster parenting with the switch to using the "in body insertion mode", which causes the <p>baz part to be inserted into the table rather than outside the table. Switching back to previous behavior where reprocessing the token uses the current insertion mode seems to resolve the failures.

[1] https://github.com/html5lib/html5lib-tests/blob/master/tree-construction/tests9.dat#L270
[2] https://github.com/html5lib/html5lib-tests/blob/master/tree-construction/tests10.dat#L236

@domenic
Copy link
Member

@domenic domenic commented on f690ad9 Mar 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TRowbotham could you file a new issue? It's easy for comments on commits to get lost. /cc @zcorpan

@TRowbotham
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@domenic I filed #6439

Please sign in to comment.