Skip to content

Commit 8d1d755

Browse files
committed
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 8737f8c commit 8d1d755

File tree

1 file changed

+138
-16
lines changed

1 file changed

+138
-16
lines changed

source

Lines changed: 138 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -100115,6 +100115,32 @@ dictionary <dfn>StorageEventInit</dfn> : <span>EventInit</span> {
100115100115
<th>Code
100116100116
<th>Description
100117100117
<tbody>
100118+
<tr>
100119+
<td><dfn data-x="parse-error-abandoned-head-element-child">abandoned-head-element-child</dfn>
100120+
<td><p>This error occurs if the parser encounters a <span data-x="syntax-start-tag">start
100121+
tag</span> for an element that is allowed by the parsing rules to be a <code>head</code>
100122+
element's child, but placed between the <code>head</code> element's
100123+
<span data-x="syntax-end-tag">end tag</span> and the <code>body</code> element's start tag or
100124+
any content that opens the <code>body</code> element if it's start tag is <span
100125+
data-x="syntax-tag-omission">omitted</span>. The parser treats such elements as child elements
100126+
of the <code>head</code> element.</p>
100127+
100128+
<div class="example">
100129+
<p>For example, consider the following markup:</p>
100130+
100131+
<pre>&lt;!DOCTYPE html>
100132+
&lt;html>
100133+
&lt;head>&lt;/head>
100134+
&lt;title>The Answer&lt;/title>
100135+
&lt;script src="foo.js">&lt;/script>
100136+
&lt;body>&lt;/body>
100137+
&lt;/html></pre>
100138+
100139+
<p>This will be parsed into:</p>
100140+
100141+
<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>
100142+
</div>
100143+
100118100144
<tr>
100119100145
<td><dfn data-x="parse-error-abrupt-closing-of-empty-comment">abrupt-closing-of-empty-comment</dfn>
100120100146
<td><p>This error occurs if the parser encounters an empty <span
@@ -100159,6 +100185,14 @@ dictionary <dfn>StorageEventInit</dfn> : <span>EventInit</span> {
100159100185
that is greater than the valid Unicode range. The parser resolves such a character reference to
100160100186
a U+FFFD REPLACEMENT CHARACTER.</p>
100161100187

100188+
<tr>
100189+
<td><dfn data-x="parse-error-closing-of-element-with-open-child-elements">closing-of-element-with-open-child-elements</dfn>
100190+
<td><p>This error occurs if the parser encounters an <span data-x="syntax-end-tag">end
100191+
tag</span> for an element that has open child elements for which end tag can not be <span
100192+
data-x="syntax-tag-omission">omitted</span> (e.g., <code
100193+
data-x="">&lt;template>&lt;div>&lt;/template></code>). In this case the parser closes such
100194+
child elements implicitly.</p>
100195+
100162100196
<tr>
100163100197
<td><dfn data-x="parse-error-control-character-in-input-stream">control-character-in-input-stream</dfn>
100164100198
<td><p>This error occurs if the <span>input stream</span> contains a <span
@@ -100175,11 +100209,31 @@ dictionary <dfn>StorageEventInit</dfn> : <span>EventInit</span> {
100175100209
references as-is except C1 control references that are replaced according to the <span>numeric
100176100210
character reference end state</span>.</p>
100177100211

100212+
<tr>
100213+
<td><dfn data-x="parse-error-disallowed-content-in-noscript-in-head">disallowed-content-in-noscript-in-head</dfn>
100214+
<td><p>This error occurs if the parser encounters any content other than <span>ASCII
100215+
whitespace</span>, <span data-x="syntax-comments">comments</span>, a <code>basefont</code>
100216+
element, a <code>bgsound</code> element, a <code>link</code> element, a <code>meta</code>
100217+
element, a <code>noframes</code> element, or a <code>style</code> element in a
100218+
<code>noscript</code> element in the <code>head</code>. In this case, the parser implicitly
100219+
closes the <code>noscript</code> element and processes the content as if it was placed after
100220+
the <code>noscript</code> element in the markup.</p>
100221+
100178100222
<tr>
100179100223
<td><dfn data-x="parse-error-duplicate-attribute">duplicate-attribute</dfn>
100180100224
<td><p>This error occurs if the parser encounters an <span
100181100225
data-x="syntax-attributes">attribute</span> in a tag that already has an attribute with the
100182-
same name. The parser ignores all such duplicate occurrences of the attribute.
100226+
same name. The parser ignores all such duplicate occurrences of the attribute.</p>
100227+
100228+
<tr>
100229+
<td><dfn data-x="parse-error-misplaced-start-tag-for-head-element">misplaced-start-tag-for-head-element</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 "head" inside or after the existing <code>head</code> element.
100232+
The parser ignores such start tags.</p>
100233+
100234+
<p class="note">Some content opens the <code>head</code> element implicitly. Therefore, a start
100235+
tag for the <code>head</code> that appear after such content will trigger this error, even
100236+
though there were no start tags for <code>head</code> present in markup before.</p>
100183100237

100184100238
<tr>
100185100239
<td><dfn data-x="parse-error-end-tag-with-attributes">end-tag-with-attributes</dfn>
@@ -100194,6 +100248,16 @@ dictionary <dfn>StorageEventInit</dfn> : <span>EventInit</span> {
100194100248
code point (e.g., <code data-x="">&lt;/div/></code>). Such a tag is treated as a regular end
100195100249
tag.</p>
100196100250

100251+
<tr>
100252+
<td><dfn data-x="parse-error-end-tag-without-matching-open-element">end-tag-without-matching-open-element</dfn>
100253+
<td><p>This error occurs if the parser encounters an <span data-x="syntax-end-tag">end
100254+
tag</span> whose tag name is not "br" or "p" and that doesn't match any open element. The
100255+
parser ignores such end tags.</p>
100256+
100257+
<p class="note">The parser can implicitly create open elements even if the markup doesn't
100258+
contain <span data-x="syntax-start-tag">start tags</span> for them (e.g., for an
100259+
<code>html</code> element).</p>
100260+
100197100261
<tr>
100198100262
<td><dfn data-x="parse-error-eof-before-tag-name">eof-before-tag-name</dfn>
100199100263
<td><p>This error occurs if the parser encounters the end of the <span>input stream</span>
@@ -100294,6 +100358,13 @@ dictionary <dfn>StorageEventInit</dfn> : <span>EventInit</span> {
100294100358
alpha</span>, a wide range of code points (including <span>ASCII digits</span>) is allowed in
100295100359
subsequent positions.</p>
100296100360

100361+
<tr>
100362+
<td><dfn data-x="parse-error-misplaced-doctype">misplaced-doctype</dfn>
100363+
<td><p>This error occurs if the parser encounters a <span
100364+
data-x="syntax-doctype">DOCTYPE</span> that is not a document preamble, i.e. it is preceded
100365+
with a content other than <span data-x="syntax-comments">comments</span> or <span>ASCII
100366+
whitespace</span>. The parser ignores such DOCTYPEs.</p>
100367+
100297100368
<tr>
100298100369
<td><dfn data-x="parse-error-missing-attribute-value">missing-attribute-value</dfn>
100299100370
<td><p>This error occurs if the parser encounters a U+003E (>) <span>code point</span> where an
@@ -100411,6 +100482,12 @@ dictionary <dfn>StorageEventInit</dfn> : <span>EventInit</span> {
100411100482
--></code>). Such a comment will be closed by the first occuring "<code data-x="">--></code>"
100412100483
<span>code point</span> sequence and everything that follows will be treated as markup.</p>
100413100484

100485+
<tr>
100486+
<td><dfn data-x="parse-error-nested-noscript-in-head">nested-noscript-in-head</dfn>
100487+
<td><p>This error occurs if the parser encounters a <span data-x="syntax-start-tag">start
100488+
tag</span> whose tag name is "noscript" in a <code>noscript</code> element in the
100489+
<code>head</code>. The parser ignores such start tags.</p>
100490+
100414100491
<tr>
100415100492
<td><dfn data-x="parse-error-non-conforming-doctype">non-conforming-doctype</dfn>
100416100493
<td><p>This error occurs if the parser encounters the <span
@@ -100462,6 +100539,14 @@ dictionary <dfn>StorageEventInit</dfn> : <span>EventInit</span> {
100462100539
point</span>. The parser resolves such character references to a U+FFFD REPLACEMENT
100463100540
CHARACTER.</p>
100464100541

100542+
<tr>
100543+
<td><dfn data-x="parse-error-open-elements-left-after-eof">open-elements-left-after-eof</dfn>
100544+
<td><p>This error occurs if the parser encounters the end of the <span>input stream</span>,
100545+
whereas there are open elements for which <span data-x="syntax-end-tag">end tag</span> can not
100546+
be <span data-x="syntax-tag-omission">omitted</span> (e.g., <code
100547+
data-x="">&lt;!DOCTYPE html>&lt;div></code>). In this case the parser closes such elements
100548+
implicitly.</p>
100549+
100465100550
<tr>
100466100551
<td><dfn data-x="parse-error-surrogate-character-reference">surrogate-character-reference</dfn>
100467100552
<td><p>This error occurs if the parser encounters a numeric <span
@@ -105552,7 +105637,8 @@ document.body.appendChild(text);
105552105637

105553105638
<dt>A DOCTYPE token</dt>
105554105639
<dd>
105555-
<p><span>Parse error</span>. Ignore the token.</p>
105640+
<p>This is a <span data-x="parse-error-misplaced-doctype">misplaced-doctype</span> <span>parse
105641+
error</span>. Ignore the token.</p>
105556105642
</dd>
105557105643

105558105644
<dt>A start tag whose tag name is "html"</dt>
@@ -105584,7 +105670,9 @@ document.body.appendChild(text);
105584105670
<dt>Any other end tag</dt>
105585105671
<dd>
105586105672

105587-
<p><span>Parse error</span>. Ignore the token.</p>
105673+
<p>This is an <span
105674+
data-x="parse-error-end-tag-without-matching-open-element">end-tag-without-matching-open-element</span>
105675+
<span>parse error</span>. Ignore the token.</p>
105588105676

105589105677
</dd>
105590105678

@@ -105631,7 +105719,8 @@ document.body.appendChild(text);
105631105719

105632105720
<dt>A DOCTYPE token</dt>
105633105721
<dd>
105634-
<p><span>Parse error</span>. Ignore the token.</p>
105722+
<p>This is a <span data-x="parse-error-misplaced-doctype">misplaced-doctype</span> <span>parse
105723+
error</span>. Ignore the token.</p>
105635105724
</dd>
105636105725

105637105726
<dt>A start tag whose tag name is "html"</dt>
@@ -105795,7 +105884,9 @@ document.body.appendChild(text);
105795105884
<dd>
105796105885

105797105886
<p>If there is no <code>template</code> element on the <span>stack of open elements</span>, then
105798-
this is a <span>parse error</span>; ignore the token.</p>
105887+
this is an <span
105888+
data-x="parse-error-end-tag-without-matching-open-element">end-tag-without-matching-open-element</span>
105889+
<span>parse error</span>; ignore the token.</p>
105799105890

105800105891
<p>Otherwise, run these steps:</p>
105801105892

@@ -105804,6 +105895,8 @@ document.body.appendChild(text);
105804105895
<li><p><span>Generate all implied end tags thoroughly</span>.</p></li>
105805105896

105806105897
<li><p>If the <span>current node</span> is not a <code>template</code> element, then this is a
105898+
<span
105899+
data-x="parse-error-closing-of-element-with-open-child-elements">closing-of-element-with-open-child-elements</span>
105807105900
<span>parse error</span>.</p></li>
105808105901

105809105902
<li><p>Pop elements from the <span>stack of open elements</span> until a <code>template</code>
@@ -105821,9 +105914,17 @@ document.body.appendChild(text);
105821105914
</dd>
105822105915

105823105916
<dt>A start tag whose tag name is "head"</dt>
105917+
<dd>
105918+
<p>This is a <span
105919+
data-x="parse-error-misplaced-start-tag-for-head-element">misplaced-start-tag-for-head-element</span>
105920+
<span>parse error</span>. Ignore the token.</p>
105921+
</dd>
105922+
105824105923
<dt>Any other end tag</dt>
105825105924
<dd>
105826-
<p><span>Parse error</span>. Ignore the token.</p>
105925+
<p>This is an <span
105926+
data-x="parse-error-end-tag-without-matching-open-element">end-tag-without-matching-open-element</span>
105927+
<span>parse error</span>. Ignore the token.</p>
105827105928
</dd>
105828105929

105829105930
<dt>Anything else</dt>
@@ -105856,7 +105957,8 @@ document.body.appendChild(text);
105856105957

105857105958
<dt>A DOCTYPE token</dt>
105858105959
<dd>
105859-
<p><span>Parse error</span>. Ignore the token.</p>
105960+
<p>This is a <span data-x="parse-error-misplaced-doctype">misplaced-doctype</span> <span>parse
105961+
error</span>. Ignore the token.</p>
105860105962
</dd>
105861105963

105862105964
<dt>A start tag whose tag name is "html"</dt>
@@ -105867,6 +105969,10 @@ document.body.appendChild(text);
105867105969

105868105970
</dd>
105869105971

105972+
<dt>A start tag whose tag name is "noscript"</dt>
105973+
<dd>This is a <span data-x="parse-error-nested-noscript-in-head">nested-noscript-in-head</span>
105974+
<span>parse error</span>. Ignore the token.</dd>
105975+
105870105976
<dt>An end tag whose tag name is "noscript"</dt>
105871105977
<dd>
105872105978

@@ -105882,8 +105988,8 @@ document.body.appendChild(text);
105882105988
<dt>A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C
105883105989
FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
105884105990
<dt>A comment token</dt>
105885-
<dt>A start tag whose tag name is one of: "basefont", "bgsound", "link", "meta", "noframes",
105886-
"style"</dt>
105991+
<dt>A start tag whose tag name is one of: "basefont", "bgsound", "head", "link", "meta",
105992+
"noframes", "style"</dt>
105887105993
<dd>
105888105994

105889105995
<p>Process the token <span>using the rules for</span> the "<span data-x="insertion mode: in
@@ -105896,18 +106002,23 @@ document.body.appendChild(text);
105896106002
<p>Act as described in the "anything else" entry below.</p>
105897106003
</dd>
105898106004

105899-
<dt>A start tag whose tag name is one of: "head", "noscript"</dt>
105900106005
<dt>Any other end tag</dt>
105901106006
<dd>
105902-
<p><span>Parse error</span>. Ignore the token.</p>
106007+
<p>This is an <span
106008+
data-x="parse-error-end-tag-without-matching-open-element">end-tag-without-matching-open-element</span>
106009+
<span>parse error</span>. Ignore the token.</p>
105903106010
</dd>
105904106011

105905106012
<dt>Anything else</dt>
105906106013
<dd>
105907106014

105908-
<!-- can't get here with an EOF and a fragment case -->
106015+
<!-- can't get here with a fragment case -->
105909106016

105910-
<p><span>Parse error</span>.</p>
106017+
<p>If the token is an end-of-file token then this is an <span
106018+
data-x="parse-error-open-elements-left-after-eof">open-elements-left-after-eof</span>
106019+
<span>parse error</span>, otherwise this is a <span
106020+
data-x="parse-error-disallowed-content-in-noscript-in-head">disallowed-content-in-noscript-in-head</span>
106021+
<span>parse error</span>.</p>
105911106022

105912106023
<!-- fake </noscript> -->
105913106024
<p>Pop the <span>current node</span> (which will be a <code>noscript</code> element) from the
@@ -105947,7 +106058,8 @@ document.body.appendChild(text);
105947106058

105948106059
<dt>A DOCTYPE token</dt>
105949106060
<dd>
105950-
<p><span>Parse error</span>. Ignore the token.</p>
106061+
<p>This is a <span data-x="parse-error-misplaced-doctype">misplaced-doctype</span> <span>parse
106062+
error</span>. Ignore the token.</p>
105951106063
</dd>
105952106064

105953106065
<dt>A start tag whose tag name is "html"</dt>
@@ -105984,7 +106096,9 @@ document.body.appendChild(text);
105984106096
"noframes", "script", "style", "template", "title"</dt>
105985106097
<dd>
105986106098

105987-
<p><span>Parse error</span>.</p>
106099+
<p>This is an <span
106100+
data-x="parse-error-abandoned-head-element-child">abandoned-head-element-child</span>
106101+
<span>parse error</span>.</p>
105988106102

105989106103
<p>Push the node pointed to by the <span><code data-x="">head</code> element pointer</span> onto
105990106104
the <span>stack of open elements</span>.</p>
@@ -106013,9 +106127,17 @@ document.body.appendChild(text);
106013106127
</dd>
106014106128

106015106129
<dt>A start tag whose tag name is "head"</dt>
106130+
<dd>
106131+
<p>This is a <span
106132+
data-x="parse-error-misplaced-start-tag-for-head-element">misplaced-start-tag-for-head-element</span>
106133+
<span>parse error</span>. Ignore the token.</p>
106134+
</dd>
106135+
106016106136
<dt>Any other end tag</dt>
106017106137
<dd>
106018-
<p><span>Parse error</span>. Ignore the token.</p>
106138+
<p>This is an <span
106139+
data-x="parse-error-end-tag-without-matching-open-element">end-tag-without-matching-open-element</span>
106140+
<span>parse error</span>. Ignore the token.</p>
106019106141
</dd>
106020106142

106021106143
<dt>Anything else</dt>

0 commit comments

Comments
 (0)