Skip to content
Permalink
Browse files

Fix #234: Change <menuitem> from void to like-<option>

- Add menuitem to "Generate implied end tags"
- <menuitem>, <hr> and <menu> pop a <menuitem>
- <menuitem> is not void and is not "special"
- An open menuitem at </body>, </html> or EOF is not a parse error.
  • Loading branch information...
zcorpan committed Mar 21, 2016
1 parent 8fdccb5 commit 5e49a20874fabef620bf7ea0be7534c73fbd58c4
Showing with 90 additions and 48 deletions.
  1. +90 −48 source
138 source
<pre>&lt;form name="npc">
&lt;label>Character name: &lt;input name=char type=text contextmenu=namemenu required>&lt;/label>
&lt;menu type=context id=namemenu>
&lt;menuitem label="Pick random name" onclick="document.forms.npc.elements.char.value = getRandomName()">
&lt;menuitem label="Prefill other fields based on name" onclick="prefillFields(document.forms.npc.elements.char.value)">
&lt;menuitem onclick="document.forms.npc.elements.char.value = getRandomName()">
Pick random name
&lt;menuitem onclick="prefillFields(document.forms.npc.elements.char.value)">
Prefill other fields based on name
&lt;/menu>
&lt;/form></pre>


<dd><code>area</code>, <code>base</code>, <code>br</code>, <code>col</code>, <code>embed</code>,
<code>hr</code>, <code>img</code>, <code>input</code>, <code>keygen</code>, <code>link</code>,
<code>menuitem</code>, <code>meta</code>, <code>param</code>, <code>source</code>,
<code>track</code>, <code>wbr</code></dd>
<code>meta</code>, <code>param</code>, <code>source</code>, <code>track</code>,
<code>wbr</code></dd>
<!-- see also other places that say VOIDLIST -->

<dt><dfn>Raw text elements</dfn></dt>
if it is immediately followed by an <code>optgroup</code> element, or if there is no more content
in the parent element.</p>

<!-- </menuitem> -->
<p>A <code>menuitem</code> element's <span data-x="syntax-end-tag">end tag</span> may be omitted
if the <code>menuitem</code> element is immediately followed by a <code>menuitem</code>,
<code>hr</code>, or <code>menu</code> element, or if there is no more content in the parent
element.</p>

<!-- <colgroup> -->
<p>A <code>colgroup</code> element's <span data-x="syntax-start-tag">start tag</span> may be
omitted if the first thing inside the <code>colgroup</code> element is a <code>col</code> element,
<code>style</code>, <code>summary</code>, <code>table</code>, <code>tbody</code>,
<code>td</code>, <code>template</code>, <code>textarea</code>, <code>tfoot</code>,
<code>th</code>, <code>thead</code>, <code>title</code>, <code>tr</code>, <code>track</code>,
<code>ul</code>, <code>wbr</code>, and <code>xmp</code>; <span>MathML <code>mi</code></span>,
<span>MathML <code>mo</code></span>, <span>MathML <code>mn</code></span>, <span>MathML
<code>ms</code></span>, <span>MathML <code>mtext</code></span>, and <span>MathML
<code>annotation-xml</code></span>; and <span>SVG <code>foreignObject</code></span>, <span>SVG
<code>desc</code></span>, and <span>SVG <code>title</code></span>.</p></dd>
<!-- We could actually put all non-HTML elements in this list, I think -->
<code>ul</code>, <code>wbr</code>, and <code>xmp</code>; MathML's <code
data-x="math:mi">mi</code>, <code data-x="math:mo">mo</code>, <code data-x="math:mn">mn</code>,
<code data-x="math:ms">ms</code>, <code data-x="math:mtext">mtext</code>, and <code
data-x="math:annotation-xml">annotation-xml</code>; and SVG's <code
data-x="">foreignObject</code>, <code data-x="">desc</code>, and <code
data-x="">title</code>.</p></dd> <!-- we could actually put all non-HTML elements in this list, I
think -->

<dt><dfn>Formatting</dfn></dt>
<dd><p>The following HTML elements are those that end up in the <span>list of active formatting

<p>When the steps below require the UA to <dfn>generate implied end tags</dfn>, then, while the
<span>current node</span> is a <code>dd</code> element, a <code>dt</code> element, an
<code>li</code> element, an <code>optgroup</code> element, an <code>option</code> element, a
<code>p</code> element, an <code>rb</code> element, an <code>rp</code> element, an <code>rt</code>
element, or an <code>rtc</code> element, the UA must pop the <span>current node</span> off the
<span>stack of open elements</span>.</p>
<code>li</code> element, a <code>menuitem</code> element, an <code>optgroup</code> element, an
<code>option</code> element, a <code>p</code> element, an <code>rb</code> element, an
<code>rp</code> element, an <code>rt</code> element, or an <code>rtc</code> element, the UA must
pop the <span>current node</span> off the <span>stack of open elements</span>.</p>

<p>If a step requires the UA to generate implied end tags but lists an element to exclude from the
process, then the UA must perform the above steps as if that element was not in the above
<ol>

<li><p>If there is a node in the <span>stack of open elements</span> that is not either a
<code>dd</code> element, a <code>dt</code> element, an <code>li</code> element, an
<code>optgroup</code> element, an <code>option</code> element, a <code>p</code> element, an
<code>rb</code> element, an <code>rp</code> element, an <code>rt</code> element, an
<code>rtc</code> element, a <code>tbody</code> element, a <code>td</code> element, a
<code>tfoot</code> element, a <code>th</code> element, a <code>thead</code> element, a
<code>tr</code> element, the <code>body</code> element, or the <code>html</code> element, then
this is a <span>parse error</span>.</p></li> <!-- (some of those are fragment cases) -->
<code>dd</code> element, a <code>dt</code> element, an <code>li</code> element, a
<code>menuitem</code> element, an <code>optgroup</code> element, an <code>option</code>
element, a <code>p</code> element, an <code>rb</code> element, an <code>rp</code> element, an
<code>rt</code> element, an <code>rtc</code> element, a <code>tbody</code> element, a
<code>td</code> element, a <code>tfoot</code> element, a <code>th</code> element, a
<code>thead</code> element, a <code>tr</code> element, the <code>body</code> element, or the
<code>html</code> element, then this is a <span>parse error</span>.</p></li> <!-- (some of
those are fragment cases) -->

<li><p><span>Stop parsing</span>.</p></li>

<!-- if we get here, the insertion mode here is forcibly "in body". -->

<p>Otherwise, if there is a node in the <span>stack of open elements</span> that is not either a
<code>dd</code> element, a <code>dt</code> element, an <code>li</code> element, an
<code>optgroup</code> element, an <code>option</code> element, a <code>p</code> element, an
<code>rb</code> element, an <code>rp</code> element, an <code>rt</code> element, an
<code>rtc</code> element, a <code>tbody</code> element, a <code>td</code> element, a
<code>tfoot</code> element, a <code>th</code> element, a <code>thead</code> element, a
<code>tr</code> element, the <code>body</code> element, or the <code>html</code> element, then
this is a <span>parse error</span>.</p> <!-- (some of those are fragment cases, e.g., for
<tbody> you'd have hit the first paragraph since the <body> wouldn't be in scope, unless it was
a fragment case) -->
<code>dd</code> element, a <code>dt</code> element, an <code>li</code> element, a
<code>menuitem</code> element, an <code>optgroup</code> element, an <code>option</code> element,
a <code>p</code> element, an <code>rb</code> element, an <code>rp</code> element, an
<code>rt</code> element, an <code>rtc</code> element, a <code>tbody</code> element, a
<code>td</code> element, a <code>tfoot</code> element, a <code>th</code> element, a
<code>thead</code> element, a <code>tr</code> element, the <code>body</code> element, or the
<code>html</code> element, then this is a <span>parse error</span>.</p> <!-- (some of those are
fragment cases, e.g., for <tbody> you'd have hit the first paragraph since the <body> wouldn't
be in scope, unless it was a fragment case) -->

<!-- If we ever change the frameset-ok flag to an insertion mode, then we'd have to somehow keep
track of its state when we switch to after-body. -->
<!-- if we get here, the insertion mode here is forcibly "in body". -->

<p>Otherwise, if there is a node in the <span>stack of open elements</span> that is not either a
<code>dd</code> element, a <code>dt</code> element, an <code>li</code> element, an
<code>optgroup</code> element, an <code>option</code> element, a <code>p</code> element, an
<code>rb</code> element, an <code>rp</code> element, an <code>rt</code> element, an
<code>rtc</code> element, a <code>tbody</code> element, a <code>td</code> element, a
<code>tfoot</code> element, a <code>th</code> element, a <code>thead</code> element, a
<code>tr</code> element, the <code>body</code> element, or the <code>html</code> element, then
this is a <span>parse error</span>.</p> <!-- (some of those are fragment cases, e.g., for
<tbody> you'd have hit the first paragraph since the <body> wouldn't be in scope, unless it was
a fragment case) -->
<code>dd</code> element, a <code>dt</code> element, an <code>li</code> element, a
<code>menuitem</code> element, an <code>optgroup</code> element, an <code>option</code> element,
a <code>p</code> element, an <code>rb</code> element, an <code>rp</code> element, an
<code>rt</code> element, an <code>rtc</code> element, a <code>tbody</code> element, a
<code>td</code> element, a <code>tfoot</code> element, a <code>th</code> element, a
<code>thead</code> element, a <code>tr</code> element, the <code>body</code> element, or the
<code>html</code> element, then this is a <span>parse error</span>.</p> <!-- (some of those are
fragment cases, e.g., for <tbody> you'd have hit the first paragraph since the <body> wouldn't
be in scope, unless it was a fragment case) -->

<!-- If we ever change the frameset-ok flag to an insertion mode, then we'd have to somehow keep
track of its state when we switch to after-body. -->
<!-- the normal ones -->
<dt>A start tag whose tag name is one of: "address", "article", "aside", "blockquote", "center",
"details", "dialog", "dir", "div", "dl", "fieldset", "figcaption", "figure", "footer", "header",
"hgroup", "main", "menu", "nav", "ol", "p", "section", "summary", "ul"</dt>
"hgroup", "main", "nav", "ol", "p", "section", "summary", "ul"</dt>
<dd>

<!-- As of May 2008 this doesn't match any browser exactly, but is as close to what IE does as I

</dd>

<!-- as normal, but close menuitem if it's the current node -->
<dt>A start tag whose tag name is "menu"</dt>
<dd>

<p>If the <span>stack of open elements</span> <span data-x="has an element in button scope">has a
<code>p</code> element in button scope</span>, then <span>close a <code>p</code>
element</span>.</p>

<!-- fake </menuitem> (maybe) -->
<p>If the <span>current node</span> is a <code>menuitem</code> element, pop that node from the
<span>stack of open elements</span>.</p>
<!-- end of fake </menuitem> -->

<p><span>Insert an HTML element</span> for the token.</p>

</dd>

<!-- as normal, but close h1-h6 if it's the current node -->
<dt>A start tag whose tag name is one of: "h1", "h2", "h3", "h4",
"h5", "h6"</dt>

<!-- end tags for non-phrasing flow content elements (and button) -->

<!-- the normal ones -->
<!-- the normal ones (and menu) -->
<dt>An end tag whose tag name is one of: "address", "article", "aside", "blockquote", "button",
"center", "details", "dialog", "dir", "div", "dl", "fieldset", "figcaption", "figure", "footer",
"header", "hgroup", "listing", "main", "menu", "nav", "ol", "pre", "section", "summary",

</dd>

<dt>A start tag whose tag name is one of: "menuitem", "param", "source", "track"</dt>
<dt>A start tag whose tag name is one of: "param", "source", "track"</dt>
<dd>

<p><span>Insert an HTML element</span> for the token. Immediately pop the <span>current
<code>p</code> element in button scope</span>, then <span>close a <code>p</code>
element</span>.</p>

<!-- fake </menuitem> (maybe) -->
<p>If the <span>current node</span> is a <code>menuitem</code> element, pop that node from the
<span>stack of open elements</span>.</p>
<!-- end of fake </menuitem> -->

<p><span>Insert an HTML element</span> for the token. Immediately pop the <span>current
node</span> off the <span>stack of open elements</span>.</p>


</dd>

<dt>A start tag whose tag name is "menuitem"</dt>
<dd>

<p>If the <span>current node</span> is a <code>menuitem</code> element, then pop the
<span>current node</span> off the <span>stack of open elements</span>.</p>

<p><span>Insert an HTML element</span> for the token.</p>

</dd>

<dt>A start tag whose tag name is one of: "rb", "rtc"</dt>
<dd>

<dt>A start <!--or end--> tag whose tag name is one of: "caption", "col", "colgroup", "frame",
"head", "tbody", "td", "tfoot", "th", "thead", "tr"</dt>
<!--<dt>An end tag whose tag name is one of: "area", "base", "basefont", "bgsound", "embed",
"hr", "iframe", "image", "img", "input", "isindex", "keygen", "link", "menuitem", "meta",
"noembed", "noframes", "param", "script", "select", "source", "style", "table", "textarea",
"title", "track", "wbr"</dt>-->
"hr", "iframe", "image", "img", "input", "isindex", "keygen", "link", "meta", "noembed",
"noframes", "param", "script", "select", "source", "style", "table", "textarea", "title",
"track", "wbr"</dt>-->
<!--<dt>An end tag whose tag name is "noscript", if the <span>scripting flag</span> is
enabled</dt>-->
<dd>
<p>If <var>current node</var> is an <code>area</code>, <code>base</code>,
<code>basefont</code>, <code>bgsound</code>, <code>br</code>, <code>col</code>,
<code>embed</code>, <code>frame</code>, <code>hr</code>, <code>img</code>,
<code>input</code>, <code>keygen</code>, <code>link</code>, <code>menuitem</code>,
<code>meta</code>, <code>param</code>, <code>source</code>, <code>track</code> or
<code>wbr</code> element, then continue on to the next child node at this point.</p>
<code>input</code>, <code>keygen</code>, <code>link</code>, <code>meta</code>,
<code>param</code>, <code>source</code>, <code>track</code> or <code>wbr</code> element,
then continue on to the next child node at this point.</p>
<!-- VOIDLIST superset -->
<!-- also, i guess: image and isindex, but we don't list those because we don't consider
those "elements", more "macros", and thus we should never serialise them -->

0 comments on commit 5e49a20

Please sign in to comment.
You can’t perform that action at this time.