Skip to content

Commit a62174f

Browse files
committed
Simplify fragment parser abort checks and fix the adoption agency Document check
1 parent 55eedc8 commit a62174f

1 file changed

Lines changed: 30 additions & 21 deletions

File tree

‎source‎

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -144143,6 +144143,16 @@ dictionary <dfn dictionary>StorageEventInit</dfn> : <span>EventInit</span> {
144143144143
<span>abort a fragment parser</span> is called while <span>fragment parser running</span> is true,
144144144144
so that the parser aborts once the current invocation finishes.</p>
144145144145

144146+
<p class="note">Once <span>fragment parser abort requested</span> is true, the
144147+
<span>tokenization</span> stage stops before its next step. A token can still be processed
144148+
afterwards, either because an earlier step of its own processing set the flag and the token is
144149+
reprocessed, or because it is a later character or end-of-file token emitted by the same
144150+
tokenization step. Steps of the <span>tree
144151+
construction</span> stage that mutate the DOM therefore check this flag first, either directly or
144152+
via <span>insert an element at the adjusted insertion location</span>, <span>insert a
144153+
character</span>, <span>insert a comment</span>, and <span>insert a processing
144154+
instruction</span>.</p>
144155+
144146144156
<p>A promise-or-null <dfn>fragment parser close promise</dfn>, initially null. When non-null, it
144147144157
is resolved when the parser <span data-x="stop parsing">stops parsing</span> or rejected if the
144148144158
stream errors while closing.</p>
@@ -148104,8 +148114,7 @@ document.body.appendChild(text);
148104148114

148105148115
<!-- end of fake <head> -->
148106148116

148107-
<p>If the parser's <span>fragment parser abort requested</span> is false, then reprocess the
148108-
current token.</p>
148117+
<p>Reprocess the current token.</p>
148109148118
</dd>
148110148119
</dl>
148111148120
</div>
@@ -148809,8 +148818,7 @@ document.body.appendChild(text);
148809148818
body</span>".</p>
148810148819
<!-- end fake <body> -->
148811148820

148812-
<p>If the parser's <span>fragment parser abort requested</span> is false, then reprocess the
148813-
current token.</p>
148821+
<p>Reprocess the current token.</p>
148814148822
</dd>
148815148823
</dl>
148816148824
</div>
@@ -150231,29 +150239,30 @@ document.body.appendChild(text);
150231150239

150232150240
<dt>"<span data-x="sanitizer-action-keep">Keep</span>"</dt>
150233150241
<dd>
150234-
<p>If the parser's <span>fragment parser abort requested</span> is false, and
150242+
<p>If the parser's <span>fragment parser abort requested</span> is false,
150235150243
<var>newElementRefNode</var> is null or its <span>parent</span> is
150236-
<var>newElementParent</var>:</p>
150244+
<var>newElementParent</var>, and <var>newElementParent</var> is not a <code>Document</code>
150245+
node or it does not have an element child:</p>
150237150246

150238150247
<ol>
150239150248
<li><p>Take all of the child nodes of <var>furthestBlock</var> and <span
150240150249
data-x="concept-node-append">append</span> them to <var>newElement</var>.</p></li>
150241150250

150242-
<li>
150243-
<p>If <var>newElement</var> is not a <span>host-including inclusive ancestor</span> of
150244-
<var>newElementParent</var>, and <var>newElementParent</var> is not a
150245-
<code>Document</code> node or it does not have an element child:</p>
150246-
150247-
<ol>
150248-
<li><p><span>Assert</span>: <span>ensure pre-insert validity</span> given
150249-
<var>newElement</var>, <var>newElementParent</var>, <var>newElementRefNode</var>, and
150250-
« » does not throw.</p></li>
150251+
<li><p><span>Assert</span>: <span>ensure pre-insert validity</span> given
150252+
<var>newElement</var>, <var>newElementParent</var>, <var>newElementRefNode</var>, and « »
150253+
does not throw.</p></li>
150251150254

150252-
<li><p><span data-x="concept-node-insert">Insert</span> <var>newElement</var> into
150253-
<var>newElementParent</var> before <var>newElementRefNode</var>.</p></li>
150254-
</ol>
150255-
</li>
150255+
<li><p><span data-x="concept-node-insert">Insert</span> <var>newElement</var> into
150256+
<var>newElementParent</var> before <var>newElementRefNode</var>.</p></li>
150256150257
</ol>
150258+
150259+
<p class="note"><var>newElementParent</var> differs from <var>furthestBlock</var> only if
150260+
<var>furthestBlock</var> was <span
150261+
data-x="dom-SanitizerConfig-replaceWithChildrenElements">replaced with its children</span>, in
150262+
which case <var>furthestBlock</var> has no children. <var>newElementParent</var> can then be a
150263+
<code>Document</code> node that already has an element child, e.g., if
150264+
<var>furthestBlock</var>'s children were being foster parented before a <code>table</code>
150265+
element that a script has since made the <span>document element</span>.</p>
150257150266
</dd>
150258150267
</dl>
150259150268
</li>
@@ -150677,8 +150686,8 @@ document.body.appendChild(text);
150677150686
<!-- no need to empty the list, we're leaving the insertion mode and the list is always emptied
150678150687
before we reenter the mode -->
150679150688

150680-
<p>Switch the <span>insertion mode</span> to the <span>original insertion mode</span>. If the
150681-
parser's <span>fragment parser abort requested</span> is false, then reprocess the token.</p>
150689+
<p>Switch the <span>insertion mode</span> to the <span>original insertion mode</span> and
150690+
reprocess the token.</p>
150682150691
</dd>
150683150692
</dl>
150684150693
</div>

0 commit comments

Comments
 (0)