Skip to content

Commit ca3fa1f

Browse files
authored
Parse errors for a bunch of insertion modes with a word "head" in them (#22)
* Add misplaced-doctype error in before head mode * Add end-tag-without-matching-open-element error in before head mode * Add in head insertion mode errors * Add in head noscript insertion mode errors * Add after head insertion mode errors * Add exceptions for end-tag-without-matching-open-element error. Limit scope of noscript error to <head> * Add missing article * Nits in abandoned-head-element-child error description * Clarify misplaced-start-tag-for-head-element * Process head in noscript in head using rules for head * nested-noscript-in-head error
1 parent 813ea0b commit ca3fa1f

File tree

1 file changed

+138
-16
lines changed

1 file changed

+138
-16
lines changed

source

+138-16
Original file line numberDiff line numberDiff line change
@@ -99858,6 +99858,32 @@ dictionary <dfn>StorageEventInit</dfn> : <span>EventInit</span> {
9985899858
<th>Code
9985999859
<th>Description
9986099860
<tbody>
99861+
<tr>
99862+
<td><dfn data-x="parse-error-abandoned-head-element-child">abandoned-head-element-child</dfn>
99863+
<td><p>This error occurs if the parser encounters a <span data-x="syntax-start-tag">start
99864+
tag</span> for an element that is allowed by the parsing rules to be a <code>head</code>
99865+
element's child, but placed between the <code>head</code> element's
99866+
<span data-x="syntax-end-tag">end tag</span> and the <code>body</code> element's start tag or
99867+
any content that opens the <code>body</code> element if it's start tag is <span
99868+
data-x="syntax-tag-omission">omitted</span>. The parser treats such elements as child elements
99869+
of the <code>head</code> element.</p>
99870+
99871+
<div class="example">
99872+
<p>For example, consider the following markup:</p>
99873+
99874+
<pre>&lt;!DOCTYPE html>
99875+
&lt;html>
99876+
&lt;head>&lt;/head>
99877+
&lt;title>The Answer&lt;/title>
99878+
&lt;script src="foo.js">&lt;/script>
99879+
&lt;body>&lt;/body>
99880+
&lt;/html></pre>
99881+
99882+
<p>This will be parsed into:</p>
99883+
99884+
<ul class="domTree"><li class="t10">DOCTYPE: <code>html</code></li><li class="t1"><code>html</code><ul><li class="t1"><code>head</code><ul><li class="t1"><code>title</code><ul><li class="t3"><code>#text</code>: <span data-x="">The Answer</span></li></ul></li><li class="t1"><code>script</code> <span class="t2"><code class="attribute name" data-x="attr-id">src</code>="<code class="attribute value" data-x="">foo.js</code>"</span></li></ul><li class="t1"><code>body</code></li></ul></li></ul>
99885+
</div>
99886+
9986199887
<tr>
9986299888
<td><dfn data-x="parse-error-abrupt-closing-of-empty-comment">abrupt-closing-of-empty-comment</dfn>
9986399889
<td><p>This error occurs if the parser encounters an empty <span
@@ -99902,6 +99928,14 @@ dictionary <dfn>StorageEventInit</dfn> : <span>EventInit</span> {
9990299928
that is greater than the valid Unicode range. The parser resolves such a character reference to
9990399929
a U+FFFD REPLACEMENT CHARACTER.</p>
9990499930

99931+
<tr>
99932+
<td><dfn data-x="parse-error-closing-of-element-with-open-child-elements">closing-of-element-with-open-child-elements</dfn>
99933+
<td><p>This error occurs if the parser encounters an <span data-x="syntax-end-tag">end
99934+
tag</span> for an element that has open child elements for which end tag can not be <span
99935+
data-x="syntax-tag-omission">omitted</span> (e.g., <code
99936+
data-x="">&lt;template>&lt;div>&lt;/template></code>). In this case the parser closes such
99937+
child elements implicitly.</p>
99938+
9990599939
<tr>
9990699940
<td><dfn data-x="parse-error-control-character-in-input-stream">control-character-in-input-stream</dfn>
9990799941
<td><p>This error occurs if the <span>input stream</span> contains a <span
@@ -99918,11 +99952,31 @@ dictionary <dfn>StorageEventInit</dfn> : <span>EventInit</span> {
9991899952
references as-is except C1 control references that are replaced according to the <span>numeric
9991999953
character reference end state</span>.</p>
9992099954

99955+
<tr>
99956+
<td><dfn data-x="parse-error-disallowed-content-in-noscript-in-head">disallowed-content-in-noscript-in-head</dfn>
99957+
<td><p>This error occurs if the parser encounters any content other than <span>ASCII
99958+
whitespace</span>, <span data-x="syntax-comments">comments</span>, a <code>basefont</code>
99959+
element, a <code>bgsound</code> element, a <code>link</code> element, a <code>meta</code>
99960+
element, a <code>noframes</code> element, or a <code>style</code> element in a
99961+
<code>noscript</code> element in the <code>head</code>. In this case, the parser implicitly
99962+
closes the <code>noscript</code> element and processes the content as if it was placed after
99963+
the <code>noscript</code> element in the markup.</p>
99964+
9992199965
<tr>
9992299966
<td><dfn data-x="parse-error-duplicate-attribute">duplicate-attribute</dfn>
9992399967
<td><p>This error occurs if the parser encounters an <span
9992499968
data-x="syntax-attributes">attribute</span> in a tag that already has an attribute with the
99925-
same name. The parser ignores all such duplicate occurrences of the attribute.
99969+
same name. The parser ignores all such duplicate occurrences of the attribute.</p>
99970+
99971+
<tr>
99972+
<td><dfn data-x="parse-error-misplaced-start-tag-for-head-element">misplaced-start-tag-for-head-element</dfn>
99973+
<td><p>This error occurs if the parser encounters a <span data-x="syntax-start-tag">start
99974+
tag</span> whose tag name is "head" inside or after the existing <code>head</code> element.
99975+
The parser ignores such start tags.</p>
99976+
99977+
<p class="note">Some content opens the <code>head</code> element implicitly. Therefore, a start
99978+
tag for the <code>head</code> that appear after such content will trigger this error, even
99979+
though there were no start tags for <code>head</code> present in markup before.</p>
9992699980

9992799981
<tr>
9992899982
<td><dfn data-x="parse-error-end-tag-with-attributes">end-tag-with-attributes</dfn>
@@ -99937,6 +99991,16 @@ dictionary <dfn>StorageEventInit</dfn> : <span>EventInit</span> {
9993799991
code point (e.g., <code data-x="">&lt;/div/></code>). Such a tag is treated as a regular end
9993899992
tag.</p>
9993999993

99994+
<tr>
99995+
<td><dfn data-x="parse-error-end-tag-without-matching-open-element">end-tag-without-matching-open-element</dfn>
99996+
<td><p>This error occurs if the parser encounters an <span data-x="syntax-end-tag">end
99997+
tag</span> whose tag name is not "br" or "p" and that doesn't match any open element. The
99998+
parser ignores such end tags.</p>
99999+
100000+
<p class="note">The parser can implicitly create open elements even if the markup doesn't
100001+
contain <span data-x="syntax-start-tag">start tags</span> for them (e.g., for an
100002+
<code>html</code> element).</p>
100003+
99940100004
<tr>
99941100005
<td><dfn data-x="parse-error-eof-before-tag-name">eof-before-tag-name</dfn>
99942100006
<td><p>This error occurs if the parser encounters the end of the <span>input stream</span>
@@ -100037,6 +100101,13 @@ dictionary <dfn>StorageEventInit</dfn> : <span>EventInit</span> {
100037100101
alpha</span>, a wide range of code points (including <span>ASCII digits</span>) is allowed in
100038100102
subsequent positions.</p>
100039100103

100104+
<tr>
100105+
<td><dfn data-x="parse-error-misplaced-doctype">misplaced-doctype</dfn>
100106+
<td><p>This error occurs if the parser encounters a <span
100107+
data-x="syntax-doctype">DOCTYPE</span> that is not a document preamble, i.e. it is preceded
100108+
with a content other than <span data-x="syntax-comments">comments</span> or <span>ASCII
100109+
whitespace</span>. The parser ignores such DOCTYPEs.</p>
100110+
100040100111
<tr>
100041100112
<td><dfn data-x="parse-error-missing-attribute-value">missing-attribute-value</dfn>
100042100113
<td><p>This error occurs if the parser encounters a U+003E (>) <span>code point</span> where an
@@ -100154,6 +100225,12 @@ dictionary <dfn>StorageEventInit</dfn> : <span>EventInit</span> {
100154100225
--></code>). Such a comment will be closed by the first occuring "<code data-x="">--></code>"
100155100226
<span>code point</span> sequence and everything that follows will be treated as markup.</p>
100156100227

100228+
<tr>
100229+
<td><dfn data-x="parse-error-nested-noscript-in-head">nested-noscript-in-head</dfn>
100230+
<td><p>This error occurs if the parser encounters a <span data-x="syntax-start-tag">start
100231+
tag</span> whose tag name is "noscript" in a <code>noscript</code> element in the
100232+
<code>head</code>. The parser ignores such start tags.</p>
100233+
100157100234
<tr>
100158100235
<td><dfn data-x="parse-error-non-conforming-doctype">non-conforming-doctype</dfn>
100159100236
<td><p>This error occurs if the parser encounters the <span
@@ -100205,6 +100282,14 @@ dictionary <dfn>StorageEventInit</dfn> : <span>EventInit</span> {
100205100282
point</span>. The parser resolves such character references to a U+FFFD REPLACEMENT
100206100283
CHARACTER.</p>
100207100284

100285+
<tr>
100286+
<td><dfn data-x="parse-error-open-elements-left-after-eof">open-elements-left-after-eof</dfn>
100287+
<td><p>This error occurs if the parser encounters the end of the <span>input stream</span>,
100288+
whereas there are open elements for which <span data-x="syntax-end-tag">end tag</span> can not
100289+
be <span data-x="syntax-tag-omission">omitted</span> (e.g., <code
100290+
data-x="">&lt;!DOCTYPE html>&lt;div></code>). In this case the parser closes such elements
100291+
implicitly.</p>
100292+
100208100293
<tr>
100209100294
<td><dfn data-x="parse-error-surrogate-character-reference">surrogate-character-reference</dfn>
100210100295
<td><p>This error occurs if the parser encounters a numeric <span
@@ -105305,7 +105390,8 @@ document.body.appendChild(text);
105305105390

105306105391
<dt>A DOCTYPE token</dt>
105307105392
<dd>
105308-
<p><span>Parse error</span>. Ignore the token.</p>
105393+
<p>This is a <span data-x="parse-error-misplaced-doctype">misplaced-doctype</span> <span>parse
105394+
error</span>. Ignore the token.</p>
105309105395
</dd>
105310105396

105311105397
<dt>A start tag whose tag name is "html"</dt>
@@ -105337,7 +105423,9 @@ document.body.appendChild(text);
105337105423
<dt>Any other end tag</dt>
105338105424
<dd>
105339105425

105340-
<p><span>Parse error</span>. Ignore the token.</p>
105426+
<p>This is an <span
105427+
data-x="parse-error-end-tag-without-matching-open-element">end-tag-without-matching-open-element</span>
105428+
<span>parse error</span>. Ignore the token.</p>
105341105429

105342105430
</dd>
105343105431

@@ -105384,7 +105472,8 @@ document.body.appendChild(text);
105384105472

105385105473
<dt>A DOCTYPE token</dt>
105386105474
<dd>
105387-
<p><span>Parse error</span>. Ignore the token.</p>
105475+
<p>This is a <span data-x="parse-error-misplaced-doctype">misplaced-doctype</span> <span>parse
105476+
error</span>. Ignore the token.</p>
105388105477
</dd>
105389105478

105390105479
<dt>A start tag whose tag name is "html"</dt>
@@ -105548,7 +105637,9 @@ document.body.appendChild(text);
105548105637
<dd>
105549105638

105550105639
<p>If there is no <code>template</code> element on the <span>stack of open elements</span>, then
105551-
this is a <span>parse error</span>; ignore the token.</p>
105640+
this is an <span
105641+
data-x="parse-error-end-tag-without-matching-open-element">end-tag-without-matching-open-element</span>
105642+
<span>parse error</span>; ignore the token.</p>
105552105643

105553105644
<p>Otherwise, run these steps:</p>
105554105645

@@ -105557,6 +105648,8 @@ document.body.appendChild(text);
105557105648
<li><p><span>Generate all implied end tags thoroughly</span>.</p></li>
105558105649

105559105650
<li><p>If the <span>current node</span> is not a <code>template</code> element, then this is a
105651+
<span
105652+
data-x="parse-error-closing-of-element-with-open-child-elements">closing-of-element-with-open-child-elements</span>
105560105653
<span>parse error</span>.</p></li>
105561105654

105562105655
<li><p>Pop elements from the <span>stack of open elements</span> until a <code>template</code>
@@ -105574,9 +105667,17 @@ document.body.appendChild(text);
105574105667
</dd>
105575105668

105576105669
<dt>A start tag whose tag name is "head"</dt>
105670+
<dd>
105671+
<p>This is a <span
105672+
data-x="parse-error-misplaced-start-tag-for-head-element">misplaced-start-tag-for-head-element</span>
105673+
<span>parse error</span>. Ignore the token.</p>
105674+
</dd>
105675+
105577105676
<dt>Any other end tag</dt>
105578105677
<dd>
105579-
<p><span>Parse error</span>. Ignore the token.</p>
105678+
<p>This is an <span
105679+
data-x="parse-error-end-tag-without-matching-open-element">end-tag-without-matching-open-element</span>
105680+
<span>parse error</span>. Ignore the token.</p>
105580105681
</dd>
105581105682

105582105683
<dt>Anything else</dt>
@@ -105609,7 +105710,8 @@ document.body.appendChild(text);
105609105710

105610105711
<dt>A DOCTYPE token</dt>
105611105712
<dd>
105612-
<p><span>Parse error</span>. Ignore the token.</p>
105713+
<p>This is a <span data-x="parse-error-misplaced-doctype">misplaced-doctype</span> <span>parse
105714+
error</span>. Ignore the token.</p>
105613105715
</dd>
105614105716

105615105717
<dt>A start tag whose tag name is "html"</dt>
@@ -105620,6 +105722,10 @@ document.body.appendChild(text);
105620105722

105621105723
</dd>
105622105724

105725+
<dt>A start tag whose tag name is "noscript"</dt>
105726+
<dd>This is a <span data-x="parse-error-nested-noscript-in-head">nested-noscript-in-head</span>
105727+
<span>parse error</span>. Ignore the token.</dd>
105728+
105623105729
<dt>An end tag whose tag name is "noscript"</dt>
105624105730
<dd>
105625105731

@@ -105635,8 +105741,8 @@ document.body.appendChild(text);
105635105741
<dt>A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C
105636105742
FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
105637105743
<dt>A comment token</dt>
105638-
<dt>A start tag whose tag name is one of: "basefont", "bgsound", "link", "meta", "noframes",
105639-
"style"</dt>
105744+
<dt>A start tag whose tag name is one of: "basefont", "bgsound", "head", "link", "meta",
105745+
"noframes", "style"</dt>
105640105746
<dd>
105641105747

105642105748
<p>Process the token <span>using the rules for</span> the "<span data-x="insertion mode: in
@@ -105649,18 +105755,23 @@ document.body.appendChild(text);
105649105755
<p>Act as described in the "anything else" entry below.</p>
105650105756
</dd>
105651105757

105652-
<dt>A start tag whose tag name is one of: "head", "noscript"</dt>
105653105758
<dt>Any other end tag</dt>
105654105759
<dd>
105655-
<p><span>Parse error</span>. Ignore the token.</p>
105760+
<p>This is an <span
105761+
data-x="parse-error-end-tag-without-matching-open-element">end-tag-without-matching-open-element</span>
105762+
<span>parse error</span>. Ignore the token.</p>
105656105763
</dd>
105657105764

105658105765
<dt>Anything else</dt>
105659105766
<dd>
105660105767

105661-
<!-- can't get here with an EOF and a fragment case -->
105768+
<!-- can't get here with a fragment case -->
105662105769

105663-
<p><span>Parse error</span>.</p>
105770+
<p>If the token is an end-of-file token then this is an <span
105771+
data-x="parse-error-open-elements-left-after-eof">open-elements-left-after-eof</span>
105772+
<span>parse error</span>, otherwise this is a <span
105773+
data-x="parse-error-disallowed-content-in-noscript-in-head">disallowed-content-in-noscript-in-head</span>
105774+
<span>parse error</span>.</p>
105664105775

105665105776
<!-- fake </noscript> -->
105666105777
<p>Pop the <span>current node</span> (which will be a <code>noscript</code> element) from the
@@ -105700,7 +105811,8 @@ document.body.appendChild(text);
105700105811

105701105812
<dt>A DOCTYPE token</dt>
105702105813
<dd>
105703-
<p><span>Parse error</span>. Ignore the token.</p>
105814+
<p>This is a <span data-x="parse-error-misplaced-doctype">misplaced-doctype</span> <span>parse
105815+
error</span>. Ignore the token.</p>
105704105816
</dd>
105705105817

105706105818
<dt>A start tag whose tag name is "html"</dt>
@@ -105737,7 +105849,9 @@ document.body.appendChild(text);
105737105849
"noframes", "script", "style", "template", "title"</dt>
105738105850
<dd>
105739105851

105740-
<p><span>Parse error</span>.</p>
105852+
<p>This is an <span
105853+
data-x="parse-error-abandoned-head-element-child">abandoned-head-element-child</span>
105854+
<span>parse error</span>.</p>
105741105855

105742105856
<p>Push the node pointed to by the <span><code data-x="">head</code> element pointer</span> onto
105743105857
the <span>stack of open elements</span>.</p>
@@ -105766,9 +105880,17 @@ document.body.appendChild(text);
105766105880
</dd>
105767105881

105768105882
<dt>A start tag whose tag name is "head"</dt>
105883+
<dd>
105884+
<p>This is a <span
105885+
data-x="parse-error-misplaced-start-tag-for-head-element">misplaced-start-tag-for-head-element</span>
105886+
<span>parse error</span>. Ignore the token.</p>
105887+
</dd>
105888+
105769105889
<dt>Any other end tag</dt>
105770105890
<dd>
105771-
<p><span>Parse error</span>. Ignore the token.</p>
105891+
<p>This is an <span
105892+
data-x="parse-error-end-tag-without-matching-open-element">end-tag-without-matching-open-element</span>
105893+
<span>parse error</span>. Ignore the token.</p>
105772105894
</dd>
105773105895

105774105896
<dt>Anything else</dt>

0 commit comments

Comments
 (0)