Skip to content

Commit

Permalink
Parse errors for a bunch of insertion modes with a word "head" in them (
Browse files Browse the repository at this point in the history
#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
  • Loading branch information
inikulin committed Dec 10, 2017
1 parent 813ea0b commit ca3fa1f
Showing 1 changed file with 138 additions and 16 deletions.
154 changes: 138 additions & 16 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -99858,6 +99858,32 @@ dictionary <dfn>StorageEventInit</dfn> : <span>EventInit</span> {
<th>Code
<th>Description
<tbody>
<tr>
<td><dfn data-x="parse-error-abandoned-head-element-child">abandoned-head-element-child</dfn>
<td><p>This error occurs if the parser encounters a <span data-x="syntax-start-tag">start
tag</span> for an element that is allowed by the parsing rules to be a <code>head</code>
element's child, but placed between the <code>head</code> element's
<span data-x="syntax-end-tag">end tag</span> and the <code>body</code> element's start tag or
any content that opens the <code>body</code> element if it's start tag is <span
data-x="syntax-tag-omission">omitted</span>. The parser treats such elements as child elements
of the <code>head</code> element.</p>

<div class="example">
<p>For example, consider the following markup:</p>

<pre>&lt;!DOCTYPE html>
&lt;html>
&lt;head>&lt;/head>
&lt;title>The Answer&lt;/title>
&lt;script src="foo.js">&lt;/script>
&lt;body>&lt;/body>
&lt;/html></pre>

<p>This will be parsed into:</p>

<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>
</div>

<tr>
<td><dfn data-x="parse-error-abrupt-closing-of-empty-comment">abrupt-closing-of-empty-comment</dfn>
<td><p>This error occurs if the parser encounters an empty <span
Expand Down Expand Up @@ -99902,6 +99928,14 @@ dictionary <dfn>StorageEventInit</dfn> : <span>EventInit</span> {
that is greater than the valid Unicode range. The parser resolves such a character reference to
a U+FFFD REPLACEMENT CHARACTER.</p>

<tr>
<td><dfn data-x="parse-error-closing-of-element-with-open-child-elements">closing-of-element-with-open-child-elements</dfn>
<td><p>This error occurs if the parser encounters an <span data-x="syntax-end-tag">end
tag</span> for an element that has open child elements for which end tag can not be <span
data-x="syntax-tag-omission">omitted</span> (e.g., <code
data-x="">&lt;template>&lt;div>&lt;/template></code>). In this case the parser closes such
child elements implicitly.</p>

<tr>
<td><dfn data-x="parse-error-control-character-in-input-stream">control-character-in-input-stream</dfn>
<td><p>This error occurs if the <span>input stream</span> contains a <span
Expand All @@ -99918,11 +99952,31 @@ dictionary <dfn>StorageEventInit</dfn> : <span>EventInit</span> {
references as-is except C1 control references that are replaced according to the <span>numeric
character reference end state</span>.</p>

<tr>
<td><dfn data-x="parse-error-disallowed-content-in-noscript-in-head">disallowed-content-in-noscript-in-head</dfn>
<td><p>This error occurs if the parser encounters any content other than <span>ASCII
whitespace</span>, <span data-x="syntax-comments">comments</span>, a <code>basefont</code>
element, a <code>bgsound</code> element, a <code>link</code> element, a <code>meta</code>
element, a <code>noframes</code> element, or a <code>style</code> element in a
<code>noscript</code> element in the <code>head</code>. In this case, the parser implicitly
closes the <code>noscript</code> element and processes the content as if it was placed after
the <code>noscript</code> element in the markup.</p>

<tr>
<td><dfn data-x="parse-error-duplicate-attribute">duplicate-attribute</dfn>
<td><p>This error occurs if the parser encounters an <span
data-x="syntax-attributes">attribute</span> in a tag that already has an attribute with the
same name. The parser ignores all such duplicate occurrences of the attribute.
same name. The parser ignores all such duplicate occurrences of the attribute.</p>

<tr>
<td><dfn data-x="parse-error-misplaced-start-tag-for-head-element">misplaced-start-tag-for-head-element</dfn>
<td><p>This error occurs if the parser encounters a <span data-x="syntax-start-tag">start
tag</span> whose tag name is "head" inside or after the existing <code>head</code> element.
The parser ignores such start tags.</p>

<p class="note">Some content opens the <code>head</code> element implicitly. Therefore, a start
tag for the <code>head</code> that appear after such content will trigger this error, even
though there were no start tags for <code>head</code> present in markup before.</p>

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

<tr>
<td><dfn data-x="parse-error-end-tag-without-matching-open-element">end-tag-without-matching-open-element</dfn>
<td><p>This error occurs if the parser encounters an <span data-x="syntax-end-tag">end
tag</span> whose tag name is not "br" or "p" and that doesn't match any open element. The
parser ignores such end tags.</p>

<p class="note">The parser can implicitly create open elements even if the markup doesn't
contain <span data-x="syntax-start-tag">start tags</span> for them (e.g., for an
<code>html</code> element).</p>

<tr>
<td><dfn data-x="parse-error-eof-before-tag-name">eof-before-tag-name</dfn>
<td><p>This error occurs if the parser encounters the end of the <span>input stream</span>
Expand Down Expand Up @@ -100037,6 +100101,13 @@ dictionary <dfn>StorageEventInit</dfn> : <span>EventInit</span> {
alpha</span>, a wide range of code points (including <span>ASCII digits</span>) is allowed in
subsequent positions.</p>

<tr>
<td><dfn data-x="parse-error-misplaced-doctype">misplaced-doctype</dfn>
<td><p>This error occurs if the parser encounters a <span
data-x="syntax-doctype">DOCTYPE</span> that is not a document preamble, i.e. it is preceded
with a content other than <span data-x="syntax-comments">comments</span> or <span>ASCII
whitespace</span>. The parser ignores such DOCTYPEs.</p>

<tr>
<td><dfn data-x="parse-error-missing-attribute-value">missing-attribute-value</dfn>
<td><p>This error occurs if the parser encounters a U+003E (>) <span>code point</span> where an
Expand Down Expand Up @@ -100154,6 +100225,12 @@ dictionary <dfn>StorageEventInit</dfn> : <span>EventInit</span> {
--></code>). Such a comment will be closed by the first occuring "<code data-x="">--></code>"
<span>code point</span> sequence and everything that follows will be treated as markup.</p>

<tr>
<td><dfn data-x="parse-error-nested-noscript-in-head">nested-noscript-in-head</dfn>
<td><p>This error occurs if the parser encounters a <span data-x="syntax-start-tag">start
tag</span> whose tag name is "noscript" in a <code>noscript</code> element in the
<code>head</code>. The parser ignores such start tags.</p>

<tr>
<td><dfn data-x="parse-error-non-conforming-doctype">non-conforming-doctype</dfn>
<td><p>This error occurs if the parser encounters the <span
Expand Down Expand Up @@ -100205,6 +100282,14 @@ dictionary <dfn>StorageEventInit</dfn> : <span>EventInit</span> {
point</span>. The parser resolves such character references to a U+FFFD REPLACEMENT
CHARACTER.</p>

<tr>
<td><dfn data-x="parse-error-open-elements-left-after-eof">open-elements-left-after-eof</dfn>
<td><p>This error occurs if the parser encounters the end of the <span>input stream</span>,
whereas there are open elements for which <span data-x="syntax-end-tag">end tag</span> can not
be <span data-x="syntax-tag-omission">omitted</span> (e.g., <code
data-x="">&lt;!DOCTYPE html>&lt;div></code>). In this case the parser closes such elements
implicitly.</p>

<tr>
<td><dfn data-x="parse-error-surrogate-character-reference">surrogate-character-reference</dfn>
<td><p>This error occurs if the parser encounters a numeric <span
Expand Down Expand Up @@ -105305,7 +105390,8 @@ document.body.appendChild(text);

<dt>A DOCTYPE token</dt>
<dd>
<p><span>Parse error</span>. Ignore the token.</p>
<p>This is a <span data-x="parse-error-misplaced-doctype">misplaced-doctype</span> <span>parse
error</span>. Ignore the token.</p>
</dd>

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

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

</dd>

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

<dt>A DOCTYPE token</dt>
<dd>
<p><span>Parse error</span>. Ignore the token.</p>
<p>This is a <span data-x="parse-error-misplaced-doctype">misplaced-doctype</span> <span>parse
error</span>. Ignore the token.</p>
</dd>

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

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

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

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

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

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

<dt>A start tag whose tag name is "head"</dt>
<dd>
<p>This is a <span
data-x="parse-error-misplaced-start-tag-for-head-element">misplaced-start-tag-for-head-element</span>
<span>parse error</span>. Ignore the token.</p>
</dd>

<dt>Any other end tag</dt>
<dd>
<p><span>Parse error</span>. Ignore the token.</p>
<p>This is an <span
data-x="parse-error-end-tag-without-matching-open-element">end-tag-without-matching-open-element</span>
<span>parse error</span>. Ignore the token.</p>
</dd>

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

<dt>A DOCTYPE token</dt>
<dd>
<p><span>Parse error</span>. Ignore the token.</p>
<p>This is a <span data-x="parse-error-misplaced-doctype">misplaced-doctype</span> <span>parse
error</span>. Ignore the token.</p>
</dd>

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

</dd>

<dt>A start tag whose tag name is "noscript"</dt>
<dd>This is a <span data-x="parse-error-nested-noscript-in-head">nested-noscript-in-head</span>
<span>parse error</span>. Ignore the token.</dd>

<dt>An end tag whose tag name is "noscript"</dt>
<dd>

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

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

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

<dt>Anything else</dt>
<dd>

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

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

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

<dt>A DOCTYPE token</dt>
<dd>
<p><span>Parse error</span>. Ignore the token.</p>
<p>This is a <span data-x="parse-error-misplaced-doctype">misplaced-doctype</span> <span>parse
error</span>. Ignore the token.</p>
</dd>

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

<p><span>Parse error</span>.</p>
<p>This is an <span
data-x="parse-error-abandoned-head-element-child">abandoned-head-element-child</span>
<span>parse error</span>.</p>

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

<dt>A start tag whose tag name is "head"</dt>
<dd>
<p>This is a <span
data-x="parse-error-misplaced-start-tag-for-head-element">misplaced-start-tag-for-head-element</span>
<span>parse error</span>. Ignore the token.</p>
</dd>

<dt>Any other end tag</dt>
<dd>
<p><span>Parse error</span>. Ignore the token.</p>
<p>This is an <span
data-x="parse-error-end-tag-without-matching-open-element">end-tag-without-matching-open-element</span>
<span>parse error</span>. Ignore the token.</p>
</dd>

<dt>Anything else</dt>
Expand Down

0 comments on commit ca3fa1f

Please sign in to comment.