[html5] r7998 - [e] (0) Very risky editorial change! Please review! This attempts to refactor th [...]

whatwg at whatwg.org whatwg at whatwg.org
Mon Jun 24 22:37:59 PDT 2013


Author: ianh
Date: 2013-06-24 22:37:58 -0700 (Mon, 24 Jun 2013)
New Revision: 7998

Modified:
   complete.html
   index
   source
Log:
[e] (0) Very risky editorial change! Please review! This attempts to refactor the parser logic so that the foster parenting is actually done inline in a single algorithm that is called by anywhere in the parser that could be affected by it. This will allow us to add the <template> magic with minimal actual magic in the prose, hopefully.
Affected topics: HTML Syntax and Parsing

Modified: complete.html
===================================================================
--- complete.html	2013-06-24 20:28:46 UTC (rev 7997)
+++ complete.html	2013-06-25 05:37:58 UTC (rev 7998)
@@ -256,7 +256,7 @@
 
   <header class=head id=head><p><a class=logo href=http://www.whatwg.org/><img alt=WHATWG height=101 src=/images/logo width=101></a></p>
    <hgroup><h1 class=allcaps>HTML</h1>
-    <h2 class="no-num no-toc">Living Standard — Last Updated 24 June 2013</h2>
+    <h2 class="no-num no-toc">Living Standard — Last Updated 25 June 2013</h2>
    </hgroup><dl><dt><strong>Web developer edition:</strong></dt>
     <dd><strong><a href=http://developers.whatwg.org/>http://developers.whatwg.org/</a></strong></dd>
     <dt>Multiple-page version:</dt>
@@ -1259,9 +1259,9 @@
        <li><a href=#tokenizing-character-references><span class=secno>12.2.4.69 </span>Tokenizing character references</a></ol></li>
      <li><a href=#tree-construction><span class=secno>12.2.5 </span>Tree construction</a>
       <ol>
-       <li><a href=#creating-and-inserting-elements><span class=secno>12.2.5.1 </span>Creating and inserting elements</a></li>
-       <li><a href=#closing-elements-that-have-implied-end-tags><span class=secno>12.2.5.2 </span>Closing elements that have implied end tags</a></li>
-       <li><a href=#foster-parenting><span class=secno>12.2.5.3 </span>Foster parenting</a></li>
+       <li><a href=#creating-and-inserting-nodes><span class=secno>12.2.5.1 </span>Creating and inserting nodes</a></li>
+       <li><a href=#parsing-elements-that-contain-only-text><span class=secno>12.2.5.2 </span>Parsing elements that contain only text</a></li>
+       <li><a href=#closing-elements-that-have-implied-end-tags><span class=secno>12.2.5.3 </span>Closing elements that have implied end tags</a></li>
        <li><a href=#parsing-main-inhtml><span class=secno>12.2.5.4 </span>The rules for parsing tokens in HTML content</a>
         <ol>
          <li><a href=#the-initial-insertion-mode><span class=secno>12.2.5.4.1 </span>The "initial" insertion mode</a></li>
@@ -86333,10 +86333,9 @@
    <li><a href=#create-an-element-for-the-token>Create an element for the token</a> for which the
    element <var title="">entry</var> was created, to obtain <var title="">new element</var>.</li>
 
-   <li>Append <var title="">new element</var> to the <a href=#current-node>current
-   node</a> and push it onto the <a href=#stack-of-open-elements>stack of open
-   elements</a> so that it is the new <a href=#current-node>current
-   node</a>.</li>
+   <li>Insert <var title="">new element</var> <a href=#insert-a-node-in-the-appropriate-place title="insert a node in the appropriate
+   place">in the appropriate place</a> and push it onto the <a href=#stack-of-open-elements>stack of open elements</a>
+   so that it is the new <a href=#current-node>current node</a>.</li>
 
    <li>Replace the entry for <var title="">entry</var> in the list
    with an entry for <var title="">new element</var>.</li>
@@ -88631,48 +88630,7 @@
    <li>A <code title="">foreignObject</code> element in the <a href=#svg-namespace>SVG namespace</a></li>
    <li>A <code title="">desc</code> element in the <a href=#svg-namespace>SVG namespace</a></li>
    <li>A <code title="">title</code> element in the <a href=#svg-namespace>SVG namespace</a></li>
-  </ul><hr><p>When the steps below require the UA to <dfn id=insert-a-character>insert a character</dfn> into a node, if that node
-  has a child immediately before where the character is to be inserted, and that child is a
-  <code><a href=#text>Text</a></code> node, then the character must be appended to that <code><a href=#text>Text</a></code> node;
-  otherwise, a new <code><a href=#text>Text</a></code> node whose data is just that character must be inserted in the
-  appropriate place.</p>
-
-  <div class=example>
-
-   <p>Here are some sample inputs to the parser and the corresponding number of <code><a href=#text>Text</a></code>
-   nodes that they result in, assuming a user agent that executes scripts.</p>
-
-   <table><thead><tr><th>Input <th>Number of <code><a href=#text>Text</a></code> nodes
-    <tbody><tr><td><pre>A<script>
-var script = document.getElementsByTagName('script')[0];
-document.body.removeChild(script);
-</script>B</pre>
-      <td>One <code><a href=#text>Text</a></code> node in the document, containing "AB".
-     <tr><td><pre>A<script>
-var text = document.createTextNode('B');
-document.body.appendChild(text);
-</script>C</pre>
-      <td>Three <code><a href=#text>Text</a></code> nodes; "A" before the script, the script's contents, and "BC" after the script (the parser appends to the <code><a href=#text>Text</a></code> node created by the script).
-     <tr><td><pre>A<script>
-var text = document.getElementsByTagName('script')[0].firstChild;
-text.data = 'B';
-document.body.appendChild(text);
-</script>C</pre>
-      <td>Two adjacent <code><a href=#text>Text</a></code> nodes in the document, containing "A" and "BC".
-     <tr><td><pre>A<table>B<tr>C</tr>D</table></pre>
-      <td>One <code><a href=#text>Text</a></code> node before the table, containing "ABCD". (This is caused by <a href=#foster-parent title="foster parent">foster parenting</a>.)
-     <tr><td><pre>A<table><tr> B</tr> C</table></pre>
-      <td>One <code><a href=#text>Text</a></code> node before the table, containing "A B C" (A-space-B-space-C). (This is caused by <a href=#foster-parent title="foster parent">foster parenting</a>.)
-     <tr><td><pre>A<table><tr> B</tr> </em>C</table></pre>
-      <td>One <code><a href=#text>Text</a></code> node before the table, containing "A BC" (A-space-B-C), and one <code><a href=#text>Text</a></code> node inside the table (as a child of a <code><a href=#the-tbody-element>tbody</a></code>) with a single space character. (Space characters separated from non-space characters by non-character tokens are not affected by <a href=#foster-parent title="foster parent">foster parenting</a>, even if those other tokens then get ignored.)
-   </table></div>
-
-  <p id=mutation-during-parsing>DOM mutation events must not fire for changes caused by the UA
-  parsing the document. This includes the parsing of any content inserted using <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code> and <code title=dom-document-writeln><a href=#dom-document-writeln>document.writeln()</a></code> calls. <a href=#refsDOMEVENTS>[DOMEVENTS]</a></p>
-
-  <p>However, mutation observers <em>do</em> fire, as required by the DOM specification.</p>
-
-  <p class=note>Not all of the tag names mentioned below are conformant tag names in this
+  </ul><p class=note>Not all of the tag names mentioned below are conformant tag names in this
   specification; many are included to handle legacy content. They still form part of the algorithm
   that implementations are required to implement to claim conformance.</p>
 
@@ -88682,7 +88640,7 @@
   depth constraints.</p>
 
 
-  <h5 id=creating-and-inserting-elements><span class=secno>12.2.5.1 </span>Creating and inserting elements</h5>
+  <h5 id=creating-and-inserting-nodes><span class=secno>12.2.5.1 </span>Creating and inserting nodes</h5>
 
   <p>When the steps below require the UA to <dfn id=create-an-element-for-the-token title="create an element for the token">create an
   element for a token</dfn> in a particular namespace, the UA must create a node implementing the
@@ -88705,23 +88663,27 @@
 
   <hr><!-- The names of these algorithms are kinda confusing; e.g. see the confusion in
          https://www.w3.org/Bugs/Public/show_bug.cgi?id=18367
-       Not sure what we could call them instead, though... --><p>When the steps below require the UA to <dfn id=insert-an-html-element>insert an HTML element</dfn> for a token, the UA
-  must first <a href=#create-an-element-for-the-token>create an element for the token</a> in the <a href=#html-namespace-0>HTML namespace</a>, and
-  then append this node to the <a href=#current-node>current node</a>, and push it onto the <a href=#stack-of-open-elements>stack of open
-  elements</a> so that it is the new <a href=#current-node>current node</a>.</p>
+       Not sure what we could call them instead, though... --><p>When the steps below require the UA to <dfn id=insert-an-html-element>insert an HTML element</dfn> for a token,
+  optionally in a specific place, the UA must run the following steps:</p>
 
-  <p>The steps below may also require that the UA insert an HTML element in a particular place, in
-  which case the UA must follow the same steps except that it must insert or append the new node in
-  the location specified instead of appending it to the <a href=#current-node>current node</a>. (This happens in
-  particular during the parsing of tables with invalid content.)</p>
+  <ol><li><p><a href=#create-an-element-for-the-token>Create an element for the token</a> in the <a href=#html-namespace-0>HTML namespace</a>.</li>
 
-  <p>If an element created by the <a href=#insert-an-html-element>insert an HTML element</a> algorithm is a
-  <a href=#form-associated-element>form-associated element</a>, and the <a href=#form-element-pointer><code title="">form</code> element
-  pointer</a> is not null, and the newly created element doesn't have a <code title=attr-fae-form><a href=#attr-fae-form>form</a></code> attribute, the user agent must <a href=#concept-form-association title=concept-form-association>associate</a> the newly created element with the
-  <code><a href=#the-form-element>form</a></code> element pointed to by the <a href=#form-element-pointer><code title="">form</code> element
-  pointer</a> when the element is inserted, instead of running the <a href=#reset-the-form-owner>reset the form
-  owner</a> algorithm.</p>
+   <li><p>If the element is a <a href=#form-associated-element>form-associated element</a>, and the <a href=#form-element-pointer><code title="">form</code> element pointer</a> is not null, and the newly created element doesn't
+   have a <code title=attr-fae-form><a href=#attr-fae-form>form</a></code> attribute, <a href=#concept-form-association title=concept-form-association>associate</a> the newly created element with the
+   <code><a href=#the-form-element>form</a></code> element pointed to by the <a href=#form-element-pointer><code title="">form</code> element
+   pointer</a>, and suppress the running of the <a href=#reset-the-form-owner>reset the form owner</a> algorithm in
+   the next step.</li>
 
+   <li><p>If no specific place has been specified, <a href=#insert-a-node-in-the-appropriate-place title="insert a node in the appropriate
+   place">insert the node in the appropriate place</a>; otherwise, if a specific place has been
+   specified, insert or append the node as specified.</li>
+
+   <li><p>Push the element onto the <a href=#stack-of-open-elements>stack of open elements</a> so that it is the new
+   <a href=#current-node>current node</a>.</li>
+
+  </ol><p class=note>A specific place is specified in in particular during the parsing of tables with
+  invalid content.</p>
+
   <hr><p>When the steps below require the UA to <dfn id=insert-a-foreign-element>insert a foreign element</dfn> for a token, the UA
   must first <a href=#create-an-element-for-the-token>create an element for the token</a> in the given namespace, and then append
   this node to the <a href=#current-node>current node</a>, and push it onto the <a href=#stack-of-open-elements>stack of open
@@ -88732,6 +88694,10 @@
   namespace</a> whose value is not the <a href=#xlink-namespace>XLink Namespace</a>, that is a <a href=#parse-error>parse
   error</a>.</p>
 
+  <p class=note>The <a href=#insert-a-foreign-element>insert a foreign element</a> algorithm isn't affected by the <a href=#foster-parent title="foster parent">foster parenting</a> logic (it doesn't use the <a href=#insert-a-node-in-the-appropriate-place>insert a node in the
+  appropriate place</a> algorithm); the <a href=#current-node>current node</a>, when the <a href=#insert-a-foreign-element>insert a
+  foreign element</a> algorithm is invoked, is always itself a non-HTML element.</p>
+
   <p>When the steps below require the user agent to <dfn id=adjust-mathml-attributes>adjust MathML attributes</dfn> for a token,
   then, if the token has an attribute named <code title="">definitionurl</code>, change its name to
   <code title="">definitionURL</code> (note the case difference).</p>
@@ -88826,7 +88792,136 @@
     <tr><td> <code title="">xml:space</code> <td> <code title="">xml</code> <td> <code title="">space</code> <td> <a href=#xml-namespace>XML namespace</a>
     <tr><td> <code title="">xmlns</code> <td> (none) <td> <code title="">xmlns</code> <td> <a href=#xmlns-namespace>XMLNS namespace</a>
     <tr><td> <code title="">xmlns:xlink</code> <td> <code title="">xmlns</code> <td> <code title="">xlink</code> <td> <a href=#xmlns-namespace>XMLNS namespace</a>
-  </table><hr><p>The <dfn id=generic-raw-text-element-parsing-algorithm>generic raw text element parsing algorithm</dfn> and the <dfn id=generic-rcdata-element-parsing-algorithm>generic RCDATA element
+  </table><hr><p>When the steps below require the user agent to <dfn id=insert-a-character>insert a character</dfn> for a token, the
+  user agent must insert it <a href=#insert-a-node-in-the-appropriate-place title="insert a node in the appropriate place">in the appropriate
+  place</a>.</p>
+
+  <hr><p>When the user agent is required to <dfn id=insert-a-node-in-the-appropriate-place>insert a node in the appropriate place</dfn>,
+  optionally using a particular <i>override target</i>, the user agent must follow the following
+  steps:</p>
+
+  <ol><li>
+
+    <p>If there was an <i>override target</i> specified, then let <var title="">target</var> be the
+    <i>override target</i>.</p>
+
+    <p>Otherwise, let <var title="">target</var> be the <a href=#current-node>current node</a>.</p>
+
+   </li>
+
+   <li>
+
+    <p>Determine the <var title="">adjusted insertion location</var> using the first matching steps
+    from the following list:</p>
+
+    <dl class=switch><dt>If <dfn id=foster-parent title="foster parent">foster parenting</dfn> is enabled and <var title="">target</var> is a <code><a href=#the-table-element>table</a></code>, <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-tfoot-element>tfoot</a></code>,
+     <code><a href=#the-thead-element>thead</a></code>, or <code><a href=#the-tr-element>tr</a></code> element</dt>
+
+     <dd>
+
+      <p class=note>Foster parenting happens when content is misnested in tables.</p>
+
+      <p>The <dfn id=foster-parent-element>foster parent element</dfn> is the parent element of the last <code><a href=#the-table-element>table</a></code>
+      element in the <a href=#stack-of-open-elements>stack of open elements</a>, if there is a <code><a href=#the-table-element>table</a></code> element and
+      it has such a parent element.</p>
+
+      <p class=note>It might have no parent or some other kind parent if a script manipulated the
+      DOM after the element was inserted by the parser.</p>
+
+      <p>If there is no <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open elements</a>
+      (<a href=#fragment-case>fragment case</a>), then the <i><a href=#foster-parent-element>foster parent element</a></i> is the first element in the
+      <a href=#stack-of-open-elements>stack of open elements</a> (the <code><a href=#the-html-element>html</a></code> element). Otherwise, if there is a
+      <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open elements</a>, but the last
+      <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open elements</a> has no parent, or its
+      parent node is not an element, then the <i><a href=#foster-parent-element>foster parent element</a></i> is the element before the
+      last <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open elements</a>.</p>
+
+      <p>If the <i><a href=#foster-parent-element>foster parent element</a></i> is the parent element of the last <code><a href=#the-table-element>table</a></code>
+      element in the <a href=#stack-of-open-elements>stack of open elements</a>, then the <var title="">adjusted insertion
+      location</var> is inside the <i><a href=#foster-parent-element>foster parent element</a></i>, immediately <em>before</em> the
+      last <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open elements</a>; otherwise, the
+      <var title="">adjusted insertion location</var> is inside the <i><a href=#foster-parent-element>foster parent element</a></i>,
+      after its last child (if any).</p>
+
+     </dd>
+
+     <dt>Otherwise</dt>
+
+     <dd>
+
+      <p>The <var title="">adjusted insertion location</var> is inside <var title="">target</var>,
+      after its last child (if any).</p>
+
+     </dd>
+
+    </dl></li>
+
+   <li>
+
+    <p>Run the first matching steps from the following list to actually perform the insertion:</p>
+
+    <dl class=switch><dt>If the node being inserted is a character</dt>
+
+     <dd>
+
+      <p>If there is a <code><a href=#text>Text</a></code> node immediately before the <var title="">adjusted
+      insertion location</var>, then append the character to that <code><a href=#text>Text</a></code> node.</p>
+
+      <p>Otherwise, create a new <code><a href=#text>Text</a></code> node whose data is just that character, and
+      insert it at the <var title="">adjusted insertion location</var>.</p>
+
+     </dd>
+
+     <dt>Otherwise</dt>
+
+     <dd>
+
+      <p>Insert the node at the <var title="">adjusted insertion location</var>.</p>
+
+     </dd>
+
+    </dl></li>
+
+  </ol><hr><div class=example>
+
+   <p>Here are some sample inputs to the parser and the corresponding number of <code><a href=#text>Text</a></code>
+   nodes that they result in, assuming a user agent that executes scripts.</p>
+
+   <table><thead><tr><th>Input <th>Number of <code><a href=#text>Text</a></code> nodes
+    <tbody><tr><td><pre>A<script>
+var script = document.getElementsByTagName('script')[0];
+document.body.removeChild(script);
+</script>B</pre>
+      <td>One <code><a href=#text>Text</a></code> node in the document, containing "AB".
+     <tr><td><pre>A<script>
+var text = document.createTextNode('B');
+document.body.appendChild(text);
+</script>C</pre>
+      <td>Three <code><a href=#text>Text</a></code> nodes; "A" before the script, the script's contents, and "BC" after the script (the parser appends to the <code><a href=#text>Text</a></code> node created by the script).
+     <tr><td><pre>A<script>
+var text = document.getElementsByTagName('script')[0].firstChild;
+text.data = 'B';
+document.body.appendChild(text);
+</script>C</pre>
+      <td>Two adjacent <code><a href=#text>Text</a></code> nodes in the document, containing "A" and "BC".
+     <tr><td><pre>A<table>B<tr>C</tr>D</table></pre>
+      <td>One <code><a href=#text>Text</a></code> node before the table, containing "ABCD". (This is caused by <a href=#foster-parent title="foster parent">foster parenting</a>.)
+     <tr><td><pre>A<table><tr> B</tr> C</table></pre>
+      <td>One <code><a href=#text>Text</a></code> node before the table, containing "A B C" (A-space-B-space-C). (This is caused by <a href=#foster-parent title="foster parent">foster parenting</a>.)
+     <tr><td><pre>A<table><tr> B</tr> </em>C</table></pre>
+      <td>One <code><a href=#text>Text</a></code> node before the table, containing "A BC" (A-space-B-C), and one <code><a href=#text>Text</a></code> node inside the table (as a child of a <code><a href=#the-tbody-element>tbody</a></code>) with a single space character. (Space characters separated from non-space characters by non-character tokens are not affected by <a href=#foster-parent title="foster parent">foster parenting</a>, even if those other tokens then get ignored.)
+   </table></div>
+
+  <p id=mutation-during-parsing>DOM mutation events must not fire for changes caused by the UA
+  parsing the document. This includes the parsing of any content inserted using <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code> and <code title=dom-document-writeln><a href=#dom-document-writeln>document.writeln()</a></code> calls. <a href=#refsDOMEVENTS>[DOMEVENTS]</a></p>
+
+  <p>However, mutation observers <em>do</em> fire, as required by the DOM specification.</p>
+
+
+
+  <h5 id=parsing-elements-that-contain-only-text><span class=secno>12.2.5.2 </span>Parsing elements that contain only text</h5>
+
+  <p>The <dfn id=generic-raw-text-element-parsing-algorithm>generic raw text element parsing algorithm</dfn> and the <dfn id=generic-rcdata-element-parsing-algorithm>generic RCDATA element
   parsing algorithm</dfn> consist of the following steps. These algorithms are always invoked in
   response to a start tag token.</p>
 
@@ -88843,7 +88938,7 @@
    <li><p>Then, switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-incdata title="insertion mode:
    text">text</a>".</li>
 
-  </ol><h5 id=closing-elements-that-have-implied-end-tags><span class=secno>12.2.5.2 </span>Closing elements that have implied end tags</h5>
+  </ol><h5 id=closing-elements-that-have-implied-end-tags><span class=secno>12.2.5.3 </span>Closing elements that have implied end tags</h5>
 
   <p>When the steps below require the UA to <dfn id=generate-implied-end-tags>generate implied end
   tags</dfn>, then, while the <a href=#current-node>current node</a> is a
@@ -88859,48 +88954,7 @@
   above steps as if that element was not in the above list.</p>
 
 
-  <h5 id=foster-parenting><span class=secno>12.2.5.3 </span>Foster parenting</h5>
 
-  <p>Foster parenting happens when content is misnested in tables.</p>
-
-  <p>When a node <var title="">node</var> is to be <dfn id=foster-parent title="foster
-  parent">foster parented</dfn>, the node <var title="">node</var>
-  must be inserted into the <i><a href=#foster-parent-element>foster parent element</a></i>.</p>
-
-  <p class=note>This typically happens as part of the <a href=#insert-an-html-element>insert an HTML element</a>
-  algorithm above: when that algorithm would normally insert the newly created node into the
-  <a href=#current-node>current node</a>, it gets inserted into the <i><a href=#foster-parent-element>foster parent element</a></i> instead.</p>
-
-  <p>The <dfn id=foster-parent-element>foster parent element</dfn> is the parent element of the
-  last <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open
-  elements</a>, if there is a <code><a href=#the-table-element>table</a></code> element and it has
-  such a parent element.</p>
-
-  <p class=note>It might have no parent or some other kind parent if
-  a script manipulated the DOM after the element was inserted by the
-  parser.</p>
-
-  <p>If there is no <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of
-  open elements</a> (<a href=#fragment-case>fragment case</a>), then the
-  <i><a href=#foster-parent-element>foster parent element</a></i> is the first element in the <a href=#stack-of-open-elements>stack
-  of open elements</a> (the <code><a href=#the-html-element>html</a></code> element). Otherwise,
-  if there is a <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open
-  elements</a>, but the last <code><a href=#the-table-element>table</a></code> element in the
-  <a href=#stack-of-open-elements>stack of open elements</a> has no parent, or its parent
-  node is not an element, then the <i><a href=#foster-parent-element>foster parent element</a></i> is the
-  element before the last <code><a href=#the-table-element>table</a></code> element in the
-  <a href=#stack-of-open-elements>stack of open elements</a>.</p>
-
-  <p>If the <i><a href=#foster-parent-element>foster parent element</a></i> is the parent element of the
-  last <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open
-  elements</a>, then <var title="">node</var> must be inserted into
-  the <i><a href=#foster-parent-element>foster parent element</a></i>, immediately <em>before</em> the
-  last <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open
-  elements</a>; otherwise, <var title="">node</var> must be
-  <em>appended</em> to the <i><a href=#foster-parent-element>foster parent element</a></i>.</p>
-
-
-
   <h5 id=parsing-main-inhtml><span class=secno>12.2.5.4 </span>The rules for parsing tokens in HTML content</h5>
 
 
@@ -89193,9 +89247,9 @@
 
    <dt>A comment token</dt>
    <dd>
-    <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <a href=#current-node>current
-    node</a> with the <code title="">data</code> attribute set to
-    the data given in the comment token.</p>
+    <p>Append a <code><a href=#comment-0>Comment</a></code> node with the <code title="">data</code> attribute set to the
+    data given in the comment token <a href=#insert-a-node-in-the-appropriate-place title="insert a node in the appropriate place">in the
+    appropriate place</a>.</p>
    </dd>
 
    <dt>A DOCTYPE token</dt>
@@ -89253,15 +89307,14 @@
    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
    U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
    <dd>
-    <p><a href=#insert-a-character title="insert a character">Insert the character</a> into
-    the <a href=#current-node>current node</a>.</p>
+    <p><a href=#insert-a-character title="insert a character">Insert the character</a>.</p>
    </dd>
 
    <dt>A comment token</dt>
    <dd>
-    <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <a href=#current-node>current
-    node</a> with the <code title="">data</code> attribute set to
-    the data given in the comment token.</p>
+    <p>Append a <code><a href=#comment-0>Comment</a></code> node with the <code title="">data</code> attribute set to the
+    data given in the comment token <a href=#insert-a-node-in-the-appropriate-place title="insert a node in the appropriate place">in the
+    appropriate place</a>.</p>
    </dd>
 
    <dt>A DOCTYPE token</dt>
@@ -89360,9 +89413,8 @@
      <code><a href=#the-script-element>script</a></code> element as <a href=#already-started>"already
      started"</a>. (<a href=#fragment-case>fragment case</a>)</li>
 
-     <li><p>Append the new element to the <a href=#current-node>current node</a>
-     and push it onto the <a href=#stack-of-open-elements>stack of open
-     elements</a>.</li>
+     <li><p><a href=#insert-a-node-in-the-appropriate-place title="insert a node in the appropriate place">Insert the node in the appropriate
+     place</a>, and then push it onto the <a href=#stack-of-open-elements>stack of open elements</a>.</li>
 
      <li><p>Switch the tokenizer to the <a href=#script-data-state>script data
      state</a>.</li>
@@ -89474,15 +89526,14 @@
    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
    U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
    <dd>
-    <p><a href=#insert-a-character title="insert a character">Insert the character</a> into
-    the <a href=#current-node>current node</a>.</p>
+    <p><a href=#insert-a-character title="insert a character">Insert the character</a>.</p>
    </dd>
 
    <dt>A comment token</dt>
    <dd>
-    <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <a href=#current-node>current
-    node</a> with the <code title="">data</code> attribute set to
-    the data given in the comment token.</p>
+    <p>Append a <code><a href=#comment-0>Comment</a></code> node with the <code title="">data</code> attribute set to the
+    data given in the comment token <a href=#insert-a-node-in-the-appropriate-place title="insert a node in the appropriate place">in the
+    appropriate place</a>.</p>
    </dd>
 
    <dt>A DOCTYPE token</dt>
@@ -89583,7 +89634,7 @@
     any.</p>
 
     <p><a href=#insert-a-character title="insert a character">Insert the token's
-    character</a> into the <a href=#current-node>current node</a>.</p>
+    character</a>.</p>
 
    </dd>
 
@@ -89594,7 +89645,7 @@
     any.</p>
 
     <p><a href=#insert-a-character title="insert a character">Insert the token's
-    character</a> into the <a href=#current-node>current node</a>.</p>
+    character</a>.</p>
 
     <p>Set the <a href=#frameset-ok-flag>frameset-ok flag</a> to "not ok".</p>
 
@@ -89602,9 +89653,9 @@
 
    <dt>A comment token</dt>
    <dd>
-    <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <a href=#current-node>current
-    node</a> with the <code title="">data</code> attribute set to
-    the data given in the comment token.</p>
+    <p>Append a <code><a href=#comment-0>Comment</a></code> node with the <code title="">data</code> attribute set to the
+    data given in the comment token <a href=#insert-a-node-in-the-appropriate-place title="insert a node in the appropriate place">in the
+    appropriate place</a>.</p>
    </dd>
 
    <dt>A DOCTYPE token</dt>
@@ -90308,22 +90359,8 @@
 
       </ol></li>
 
-     <li>
+     <li><p>Insert whatever <var title="">last node</var> ended up being in the previous step <a href=#insert-a-node-in-the-appropriate-place title="insert a node in the appropriate place">in the appropriate place</a>, but using <var title="">common ancestor</var> as the <i>override target</i>.</li>
 
-      <p>If the <var title="">common ancestor</var> node is a
-      <code><a href=#the-table-element>table</a></code>, <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-tfoot-element>tfoot</a></code>,
-      <code><a href=#the-thead-element>thead</a></code>, or <code><a href=#the-tr-element>tr</a></code> element, then,
-      <a href=#foster-parent>foster parent</a> whatever <var title="">last
-      node</var> ended up being in the previous step, first removing
-      it from its previous parent node if any.</p>
-
-      <p>Otherwise, append whatever <var title="">last node</var>
-      ended up being in the previous step to the <var title="">common
-      ancestor</var> node, first removing it from its previous parent
-      node if any.</p>
-
-     </li>
-
      <li><p><a href=#create-an-element-for-the-token>Create an element for the token</a> for which the
      <var title="">formatting element</var> was created.</li>
 
@@ -90822,7 +90859,7 @@
    <dd>
 
     <p><a href=#insert-a-character title="insert a character">Insert the token's
-    character</a> into the <a href=#current-node>current node</a>.</p>
+    character</a>.</p>
 
     <p class=note>This can never be a U+0000 NULL character; the
     tokenizer converts those to U+FFFD REPLACEMENT CHARACTER
@@ -90979,9 +91016,9 @@
 
    <dt>A comment token</dt>
    <dd>
-    <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <a href=#current-node>current
-    node</a> with the <code title="">data</code> attribute set to
-    the data given in the comment token.</p>
+    <p>Append a <code><a href=#comment-0>Comment</a></code> node with the <code title="">data</code> attribute set to the
+    data given in the comment token <a href=#insert-a-node-in-the-appropriate-place title="insert a node in the appropriate place">in the
+    appropriate place</a>.</p>
    </dd>
 
    <dt>A DOCTYPE token</dt>
@@ -91143,13 +91180,10 @@
    <dt>Anything else</dt>
    <dd>
 
-    <p><a href=#parse-error>Parse error</a>. Process the token <a href=#using-the-rules-for>using the
-    rules for</a> the "<a href=#parsing-main-inbody title="insertion mode: in body">in
-    body</a>" <a href=#insertion-mode>insertion mode</a>, except that whenever a
-    node would be inserted into the <a href=#current-node>current node</a> when the
-    <a href=#current-node>current node</a> is a <code><a href=#the-table-element>table</a></code>,
-    <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-tfoot-element>tfoot</a></code>, <code><a href=#the-thead-element>thead</a></code>, or
-    <code><a href=#the-tr-element>tr</a></code> element, then it must instead be <a href=#foster-parent title="foster parent">foster parented</a>.</p>
+    <p><a href=#parse-error>Parse error</a>. Enable <a href=#foster-parent title="foster parent">foster parenting</a>, process
+    the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody title="insertion mode: in body">in
+    body</a>" <a href=#insertion-mode>insertion mode</a>, and then disable <a href=#foster-parent title="foster parent">foster
+    parenting</a>.</p>
 
    </dd>
 
@@ -91206,7 +91240,7 @@
 
     <p>Otherwise, <a href=#insert-a-character title="insert a character">insert the
     characters</a> given by the <var><a href=#pending-table-character-tokens>pending table character
-    tokens</a></var> list into the <a href=#current-node>current node</a>.</p> <!--
+    tokens</a></var> list.</p> <!--
     i.e. inter-element whitespace in the table model isn't foster
     parented -->
 
@@ -91283,15 +91317,14 @@
    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
    U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
    <dd>
-    <p><a href=#insert-a-character title="insert a character">Insert the character</a> into
-    the <a href=#current-node>current node</a>.</p>
+    <p><a href=#insert-a-character title="insert a character">Insert the character</a>.</p>
    </dd>
 
    <dt>A comment token</dt>
    <dd>
-    <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <a href=#current-node>current
-    node</a> with the <code title="">data</code> attribute set to
-    the data given in the comment token.</p>
+    <p>Append a <code><a href=#comment-0>Comment</a></code> node with the <code title="">data</code> attribute set to the
+    data given in the comment token <a href=#insert-a-node-in-the-appropriate-place title="insert a node in the appropriate place">in the
+    appropriate place</a>.</p>
    </dd>
 
    <dt>A DOCTYPE token</dt>
@@ -91644,14 +91677,14 @@
    <dt>Any other character token</dt>
    <dd>
     <p><a href=#insert-a-character title="insert a character">Insert the token's
-    character</a> into the <a href=#current-node>current node</a>.</p>
+    character</a>.</p>
    </dd>
 
    <dt>A comment token</dt>
    <dd>
-    <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <a href=#current-node>current
-    node</a> with the <code title="">data</code> attribute set to
-    the data given in the comment token.</p>
+    <p>Append a <code><a href=#comment-0>Comment</a></code> node with the <code title="">data</code> attribute set to the
+    data given in the comment token <a href=#insert-a-node-in-the-appropriate-place title="insert a node in the appropriate place">in the
+    appropriate place</a>.</p>
    </dd>
 
    <dt>A DOCTYPE token</dt>
@@ -91878,15 +91911,14 @@
    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
    U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
    <dd>
-    <p><a href=#insert-a-character title="insert a character">Insert the character</a> into
-    the <a href=#current-node>current node</a>.</p>
+    <p><a href=#insert-a-character title="insert a character">Insert the character</a>.</p>
    </dd>
 
    <dt>A comment token</dt>
    <dd>
-    <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <a href=#current-node>current
-    node</a> with the <code title="">data</code> attribute set to
-    the data given in the comment token.</p>
+    <p>Append a <code><a href=#comment-0>Comment</a></code> node with the <code title="">data</code> attribute set to the
+    data given in the comment token <a href=#insert-a-node-in-the-appropriate-place title="insert a node in the appropriate place">in the
+    appropriate place</a>.</p>
    </dd>
 
    <dt>A DOCTYPE token</dt>
@@ -91971,15 +92003,14 @@
    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
    U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
    <dd>
-    <p><a href=#insert-a-character title="insert a character">Insert the character</a> into
-    the <a href=#current-node>current node</a>.</p>
+    <p><a href=#insert-a-character title="insert a character">Insert the character</a>.</p>
    </dd>
 
    <dt>A comment token</dt>
    <dd>
-    <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <a href=#current-node>current
-    node</a> with the <code title="">data</code> attribute set to
-    the data given in the comment token.</p>
+    <p>Append a <code><a href=#comment-0>Comment</a></code> node with the <code title="">data</code> attribute set to the
+    data given in the comment token <a href=#insert-a-node-in-the-appropriate-place title="insert a node in the appropriate place">in the
+    appropriate place</a>.</p>
    </dd>
 
    <dt>A DOCTYPE token</dt>
@@ -92093,7 +92124,7 @@
    <dd>
 
     <p><a href=#parse-error>Parse error</a>. <a href=#insert-a-character title="insert a character">Insert a U+FFFD REPLACEMENT
-    CHARACTER character</a> into the <a href=#current-node>current node</a>.</p>
+    CHARACTER character</a>.</p>
 
    </dd>
 
@@ -92101,16 +92132,14 @@
    FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
    <dd>
 
-    <p><a href=#insert-a-character title="insert a character">Insert the token's character</a> into the <a href=#current-node>current
-    node</a>.</p>
+    <p><a href=#insert-a-character title="insert a character">Insert the token's character</a>.</p>
 
    </dd>
 
    <dt>Any other character token</dt>
    <dd>
 
-    <p><a href=#insert-a-character title="insert a character">Insert the token's character</a> into the <a href=#current-node>current
-    node</a>.</p>
+    <p><a href=#insert-a-character title="insert a character">Insert the token's character</a>.</p>
 
     <p>Set the <a href=#frameset-ok-flag>frameset-ok flag</a> to "not ok".</p>
 
@@ -92119,7 +92148,9 @@
    <dt>A comment token</dt>
    <dd>
 
-    <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <a href=#current-node>current node</a> with the <code title="">data</code> attribute set to the data given in the comment token.</p>
+    <p>Append a <code><a href=#comment-0>Comment</a></code> node with the <code title="">data</code> attribute set to the
+    data given in the comment token <a href=#insert-a-node-in-the-appropriate-place title="insert a node in the appropriate place">in the
+    appropriate place</a>.</p>
 
    </dd>
 
@@ -93268,7 +93299,6 @@
   listed above.</i></p>
 
 
-
   <h2 id=the-xhtml-syntax><span class=secno>13 </span><dfn id=xhtml>The XHTML syntax</dfn></h2>
 
   <p class=note>This section only describes the rules for XML

Modified: index
===================================================================
--- index	2013-06-24 20:28:46 UTC (rev 7997)
+++ index	2013-06-25 05:37:58 UTC (rev 7998)
@@ -256,7 +256,7 @@
 
   <header class=head id=head><p><a class=logo href=http://www.whatwg.org/><img alt=WHATWG height=101 src=/images/logo width=101></a></p>
    <hgroup><h1 class=allcaps>HTML</h1>
-    <h2 class="no-num no-toc">Living Standard — Last Updated 24 June 2013</h2>
+    <h2 class="no-num no-toc">Living Standard — Last Updated 25 June 2013</h2>
    </hgroup><dl><dt><strong>Web developer edition:</strong></dt>
     <dd><strong><a href=http://developers.whatwg.org/>http://developers.whatwg.org/</a></strong></dd>
     <dt>Multiple-page version:</dt>
@@ -1259,9 +1259,9 @@
        <li><a href=#tokenizing-character-references><span class=secno>12.2.4.69 </span>Tokenizing character references</a></ol></li>
      <li><a href=#tree-construction><span class=secno>12.2.5 </span>Tree construction</a>
       <ol>
-       <li><a href=#creating-and-inserting-elements><span class=secno>12.2.5.1 </span>Creating and inserting elements</a></li>
-       <li><a href=#closing-elements-that-have-implied-end-tags><span class=secno>12.2.5.2 </span>Closing elements that have implied end tags</a></li>
-       <li><a href=#foster-parenting><span class=secno>12.2.5.3 </span>Foster parenting</a></li>
+       <li><a href=#creating-and-inserting-nodes><span class=secno>12.2.5.1 </span>Creating and inserting nodes</a></li>
+       <li><a href=#parsing-elements-that-contain-only-text><span class=secno>12.2.5.2 </span>Parsing elements that contain only text</a></li>
+       <li><a href=#closing-elements-that-have-implied-end-tags><span class=secno>12.2.5.3 </span>Closing elements that have implied end tags</a></li>
        <li><a href=#parsing-main-inhtml><span class=secno>12.2.5.4 </span>The rules for parsing tokens in HTML content</a>
         <ol>
          <li><a href=#the-initial-insertion-mode><span class=secno>12.2.5.4.1 </span>The "initial" insertion mode</a></li>
@@ -86333,10 +86333,9 @@
    <li><a href=#create-an-element-for-the-token>Create an element for the token</a> for which the
    element <var title="">entry</var> was created, to obtain <var title="">new element</var>.</li>
 
-   <li>Append <var title="">new element</var> to the <a href=#current-node>current
-   node</a> and push it onto the <a href=#stack-of-open-elements>stack of open
-   elements</a> so that it is the new <a href=#current-node>current
-   node</a>.</li>
+   <li>Insert <var title="">new element</var> <a href=#insert-a-node-in-the-appropriate-place title="insert a node in the appropriate
+   place">in the appropriate place</a> and push it onto the <a href=#stack-of-open-elements>stack of open elements</a>
+   so that it is the new <a href=#current-node>current node</a>.</li>
 
    <li>Replace the entry for <var title="">entry</var> in the list
    with an entry for <var title="">new element</var>.</li>
@@ -88631,48 +88630,7 @@
    <li>A <code title="">foreignObject</code> element in the <a href=#svg-namespace>SVG namespace</a></li>
    <li>A <code title="">desc</code> element in the <a href=#svg-namespace>SVG namespace</a></li>
    <li>A <code title="">title</code> element in the <a href=#svg-namespace>SVG namespace</a></li>
-  </ul><hr><p>When the steps below require the UA to <dfn id=insert-a-character>insert a character</dfn> into a node, if that node
-  has a child immediately before where the character is to be inserted, and that child is a
-  <code><a href=#text>Text</a></code> node, then the character must be appended to that <code><a href=#text>Text</a></code> node;
-  otherwise, a new <code><a href=#text>Text</a></code> node whose data is just that character must be inserted in the
-  appropriate place.</p>
-
-  <div class=example>
-
-   <p>Here are some sample inputs to the parser and the corresponding number of <code><a href=#text>Text</a></code>
-   nodes that they result in, assuming a user agent that executes scripts.</p>
-
-   <table><thead><tr><th>Input <th>Number of <code><a href=#text>Text</a></code> nodes
-    <tbody><tr><td><pre>A<script>
-var script = document.getElementsByTagName('script')[0];
-document.body.removeChild(script);
-</script>B</pre>
-      <td>One <code><a href=#text>Text</a></code> node in the document, containing "AB".
-     <tr><td><pre>A<script>
-var text = document.createTextNode('B');
-document.body.appendChild(text);
-</script>C</pre>
-      <td>Three <code><a href=#text>Text</a></code> nodes; "A" before the script, the script's contents, and "BC" after the script (the parser appends to the <code><a href=#text>Text</a></code> node created by the script).
-     <tr><td><pre>A<script>
-var text = document.getElementsByTagName('script')[0].firstChild;
-text.data = 'B';
-document.body.appendChild(text);
-</script>C</pre>
-      <td>Two adjacent <code><a href=#text>Text</a></code> nodes in the document, containing "A" and "BC".
-     <tr><td><pre>A<table>B<tr>C</tr>D</table></pre>
-      <td>One <code><a href=#text>Text</a></code> node before the table, containing "ABCD". (This is caused by <a href=#foster-parent title="foster parent">foster parenting</a>.)
-     <tr><td><pre>A<table><tr> B</tr> C</table></pre>
-      <td>One <code><a href=#text>Text</a></code> node before the table, containing "A B C" (A-space-B-space-C). (This is caused by <a href=#foster-parent title="foster parent">foster parenting</a>.)
-     <tr><td><pre>A<table><tr> B</tr> </em>C</table></pre>
-      <td>One <code><a href=#text>Text</a></code> node before the table, containing "A BC" (A-space-B-C), and one <code><a href=#text>Text</a></code> node inside the table (as a child of a <code><a href=#the-tbody-element>tbody</a></code>) with a single space character. (Space characters separated from non-space characters by non-character tokens are not affected by <a href=#foster-parent title="foster parent">foster parenting</a>, even if those other tokens then get ignored.)
-   </table></div>
-
-  <p id=mutation-during-parsing>DOM mutation events must not fire for changes caused by the UA
-  parsing the document. This includes the parsing of any content inserted using <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code> and <code title=dom-document-writeln><a href=#dom-document-writeln>document.writeln()</a></code> calls. <a href=#refsDOMEVENTS>[DOMEVENTS]</a></p>
-
-  <p>However, mutation observers <em>do</em> fire, as required by the DOM specification.</p>
-
-  <p class=note>Not all of the tag names mentioned below are conformant tag names in this
+  </ul><p class=note>Not all of the tag names mentioned below are conformant tag names in this
   specification; many are included to handle legacy content. They still form part of the algorithm
   that implementations are required to implement to claim conformance.</p>
 
@@ -88682,7 +88640,7 @@
   depth constraints.</p>
 
 
-  <h5 id=creating-and-inserting-elements><span class=secno>12.2.5.1 </span>Creating and inserting elements</h5>
+  <h5 id=creating-and-inserting-nodes><span class=secno>12.2.5.1 </span>Creating and inserting nodes</h5>
 
   <p>When the steps below require the UA to <dfn id=create-an-element-for-the-token title="create an element for the token">create an
   element for a token</dfn> in a particular namespace, the UA must create a node implementing the
@@ -88705,23 +88663,27 @@
 
   <hr><!-- The names of these algorithms are kinda confusing; e.g. see the confusion in
          https://www.w3.org/Bugs/Public/show_bug.cgi?id=18367
-       Not sure what we could call them instead, though... --><p>When the steps below require the UA to <dfn id=insert-an-html-element>insert an HTML element</dfn> for a token, the UA
-  must first <a href=#create-an-element-for-the-token>create an element for the token</a> in the <a href=#html-namespace-0>HTML namespace</a>, and
-  then append this node to the <a href=#current-node>current node</a>, and push it onto the <a href=#stack-of-open-elements>stack of open
-  elements</a> so that it is the new <a href=#current-node>current node</a>.</p>
+       Not sure what we could call them instead, though... --><p>When the steps below require the UA to <dfn id=insert-an-html-element>insert an HTML element</dfn> for a token,
+  optionally in a specific place, the UA must run the following steps:</p>
 
-  <p>The steps below may also require that the UA insert an HTML element in a particular place, in
-  which case the UA must follow the same steps except that it must insert or append the new node in
-  the location specified instead of appending it to the <a href=#current-node>current node</a>. (This happens in
-  particular during the parsing of tables with invalid content.)</p>
+  <ol><li><p><a href=#create-an-element-for-the-token>Create an element for the token</a> in the <a href=#html-namespace-0>HTML namespace</a>.</li>
 
-  <p>If an element created by the <a href=#insert-an-html-element>insert an HTML element</a> algorithm is a
-  <a href=#form-associated-element>form-associated element</a>, and the <a href=#form-element-pointer><code title="">form</code> element
-  pointer</a> is not null, and the newly created element doesn't have a <code title=attr-fae-form><a href=#attr-fae-form>form</a></code> attribute, the user agent must <a href=#concept-form-association title=concept-form-association>associate</a> the newly created element with the
-  <code><a href=#the-form-element>form</a></code> element pointed to by the <a href=#form-element-pointer><code title="">form</code> element
-  pointer</a> when the element is inserted, instead of running the <a href=#reset-the-form-owner>reset the form
-  owner</a> algorithm.</p>
+   <li><p>If the element is a <a href=#form-associated-element>form-associated element</a>, and the <a href=#form-element-pointer><code title="">form</code> element pointer</a> is not null, and the newly created element doesn't
+   have a <code title=attr-fae-form><a href=#attr-fae-form>form</a></code> attribute, <a href=#concept-form-association title=concept-form-association>associate</a> the newly created element with the
+   <code><a href=#the-form-element>form</a></code> element pointed to by the <a href=#form-element-pointer><code title="">form</code> element
+   pointer</a>, and suppress the running of the <a href=#reset-the-form-owner>reset the form owner</a> algorithm in
+   the next step.</li>
 
+   <li><p>If no specific place has been specified, <a href=#insert-a-node-in-the-appropriate-place title="insert a node in the appropriate
+   place">insert the node in the appropriate place</a>; otherwise, if a specific place has been
+   specified, insert or append the node as specified.</li>
+
+   <li><p>Push the element onto the <a href=#stack-of-open-elements>stack of open elements</a> so that it is the new
+   <a href=#current-node>current node</a>.</li>
+
+  </ol><p class=note>A specific place is specified in in particular during the parsing of tables with
+  invalid content.</p>
+
   <hr><p>When the steps below require the UA to <dfn id=insert-a-foreign-element>insert a foreign element</dfn> for a token, the UA
   must first <a href=#create-an-element-for-the-token>create an element for the token</a> in the given namespace, and then append
   this node to the <a href=#current-node>current node</a>, and push it onto the <a href=#stack-of-open-elements>stack of open
@@ -88732,6 +88694,10 @@
   namespace</a> whose value is not the <a href=#xlink-namespace>XLink Namespace</a>, that is a <a href=#parse-error>parse
   error</a>.</p>
 
+  <p class=note>The <a href=#insert-a-foreign-element>insert a foreign element</a> algorithm isn't affected by the <a href=#foster-parent title="foster parent">foster parenting</a> logic (it doesn't use the <a href=#insert-a-node-in-the-appropriate-place>insert a node in the
+  appropriate place</a> algorithm); the <a href=#current-node>current node</a>, when the <a href=#insert-a-foreign-element>insert a
+  foreign element</a> algorithm is invoked, is always itself a non-HTML element.</p>
+
   <p>When the steps below require the user agent to <dfn id=adjust-mathml-attributes>adjust MathML attributes</dfn> for a token,
   then, if the token has an attribute named <code title="">definitionurl</code>, change its name to
   <code title="">definitionURL</code> (note the case difference).</p>
@@ -88826,7 +88792,136 @@
     <tr><td> <code title="">xml:space</code> <td> <code title="">xml</code> <td> <code title="">space</code> <td> <a href=#xml-namespace>XML namespace</a>
     <tr><td> <code title="">xmlns</code> <td> (none) <td> <code title="">xmlns</code> <td> <a href=#xmlns-namespace>XMLNS namespace</a>
     <tr><td> <code title="">xmlns:xlink</code> <td> <code title="">xmlns</code> <td> <code title="">xlink</code> <td> <a href=#xmlns-namespace>XMLNS namespace</a>
-  </table><hr><p>The <dfn id=generic-raw-text-element-parsing-algorithm>generic raw text element parsing algorithm</dfn> and the <dfn id=generic-rcdata-element-parsing-algorithm>generic RCDATA element
+  </table><hr><p>When the steps below require the user agent to <dfn id=insert-a-character>insert a character</dfn> for a token, the
+  user agent must insert it <a href=#insert-a-node-in-the-appropriate-place title="insert a node in the appropriate place">in the appropriate
+  place</a>.</p>
+
+  <hr><p>When the user agent is required to <dfn id=insert-a-node-in-the-appropriate-place>insert a node in the appropriate place</dfn>,
+  optionally using a particular <i>override target</i>, the user agent must follow the following
+  steps:</p>
+
+  <ol><li>
+
+    <p>If there was an <i>override target</i> specified, then let <var title="">target</var> be the
+    <i>override target</i>.</p>
+
+    <p>Otherwise, let <var title="">target</var> be the <a href=#current-node>current node</a>.</p>
+
+   </li>
+
+   <li>
+
+    <p>Determine the <var title="">adjusted insertion location</var> using the first matching steps
+    from the following list:</p>
+
+    <dl class=switch><dt>If <dfn id=foster-parent title="foster parent">foster parenting</dfn> is enabled and <var title="">target</var> is a <code><a href=#the-table-element>table</a></code>, <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-tfoot-element>tfoot</a></code>,
+     <code><a href=#the-thead-element>thead</a></code>, or <code><a href=#the-tr-element>tr</a></code> element</dt>
+
+     <dd>
+
+      <p class=note>Foster parenting happens when content is misnested in tables.</p>
+
+      <p>The <dfn id=foster-parent-element>foster parent element</dfn> is the parent element of the last <code><a href=#the-table-element>table</a></code>
+      element in the <a href=#stack-of-open-elements>stack of open elements</a>, if there is a <code><a href=#the-table-element>table</a></code> element and
+      it has such a parent element.</p>
+
+      <p class=note>It might have no parent or some other kind parent if a script manipulated the
+      DOM after the element was inserted by the parser.</p>
+
+      <p>If there is no <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open elements</a>
+      (<a href=#fragment-case>fragment case</a>), then the <i><a href=#foster-parent-element>foster parent element</a></i> is the first element in the
+      <a href=#stack-of-open-elements>stack of open elements</a> (the <code><a href=#the-html-element>html</a></code> element). Otherwise, if there is a
+      <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open elements</a>, but the last
+      <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open elements</a> has no parent, or its
+      parent node is not an element, then the <i><a href=#foster-parent-element>foster parent element</a></i> is the element before the
+      last <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open elements</a>.</p>
+
+      <p>If the <i><a href=#foster-parent-element>foster parent element</a></i> is the parent element of the last <code><a href=#the-table-element>table</a></code>
+      element in the <a href=#stack-of-open-elements>stack of open elements</a>, then the <var title="">adjusted insertion
+      location</var> is inside the <i><a href=#foster-parent-element>foster parent element</a></i>, immediately <em>before</em> the
+      last <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open elements</a>; otherwise, the
+      <var title="">adjusted insertion location</var> is inside the <i><a href=#foster-parent-element>foster parent element</a></i>,
+      after its last child (if any).</p>
+
+     </dd>
+
+     <dt>Otherwise</dt>
+
+     <dd>
+
+      <p>The <var title="">adjusted insertion location</var> is inside <var title="">target</var>,
+      after its last child (if any).</p>
+
+     </dd>
+
+    </dl></li>
+
+   <li>
+
+    <p>Run the first matching steps from the following list to actually perform the insertion:</p>
+
+    <dl class=switch><dt>If the node being inserted is a character</dt>
+
+     <dd>
+
+      <p>If there is a <code><a href=#text>Text</a></code> node immediately before the <var title="">adjusted
+      insertion location</var>, then append the character to that <code><a href=#text>Text</a></code> node.</p>
+
+      <p>Otherwise, create a new <code><a href=#text>Text</a></code> node whose data is just that character, and
+      insert it at the <var title="">adjusted insertion location</var>.</p>
+
+     </dd>
+
+     <dt>Otherwise</dt>
+
+     <dd>
+
+      <p>Insert the node at the <var title="">adjusted insertion location</var>.</p>
+
+     </dd>
+
+    </dl></li>
+
+  </ol><hr><div class=example>
+
+   <p>Here are some sample inputs to the parser and the corresponding number of <code><a href=#text>Text</a></code>
+   nodes that they result in, assuming a user agent that executes scripts.</p>
+
+   <table><thead><tr><th>Input <th>Number of <code><a href=#text>Text</a></code> nodes
+    <tbody><tr><td><pre>A<script>
+var script = document.getElementsByTagName('script')[0];
+document.body.removeChild(script);
+</script>B</pre>
+      <td>One <code><a href=#text>Text</a></code> node in the document, containing "AB".
+     <tr><td><pre>A<script>
+var text = document.createTextNode('B');
+document.body.appendChild(text);
+</script>C</pre>
+      <td>Three <code><a href=#text>Text</a></code> nodes; "A" before the script, the script's contents, and "BC" after the script (the parser appends to the <code><a href=#text>Text</a></code> node created by the script).
+     <tr><td><pre>A<script>
+var text = document.getElementsByTagName('script')[0].firstChild;
+text.data = 'B';
+document.body.appendChild(text);
+</script>C</pre>
+      <td>Two adjacent <code><a href=#text>Text</a></code> nodes in the document, containing "A" and "BC".
+     <tr><td><pre>A<table>B<tr>C</tr>D</table></pre>
+      <td>One <code><a href=#text>Text</a></code> node before the table, containing "ABCD". (This is caused by <a href=#foster-parent title="foster parent">foster parenting</a>.)
+     <tr><td><pre>A<table><tr> B</tr> C</table></pre>
+      <td>One <code><a href=#text>Text</a></code> node before the table, containing "A B C" (A-space-B-space-C). (This is caused by <a href=#foster-parent title="foster parent">foster parenting</a>.)
+     <tr><td><pre>A<table><tr> B</tr> </em>C</table></pre>
+      <td>One <code><a href=#text>Text</a></code> node before the table, containing "A BC" (A-space-B-C), and one <code><a href=#text>Text</a></code> node inside the table (as a child of a <code><a href=#the-tbody-element>tbody</a></code>) with a single space character. (Space characters separated from non-space characters by non-character tokens are not affected by <a href=#foster-parent title="foster parent">foster parenting</a>, even if those other tokens then get ignored.)
+   </table></div>
+
+  <p id=mutation-during-parsing>DOM mutation events must not fire for changes caused by the UA
+  parsing the document. This includes the parsing of any content inserted using <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code> and <code title=dom-document-writeln><a href=#dom-document-writeln>document.writeln()</a></code> calls. <a href=#refsDOMEVENTS>[DOMEVENTS]</a></p>
+
+  <p>However, mutation observers <em>do</em> fire, as required by the DOM specification.</p>
+
+
+
+  <h5 id=parsing-elements-that-contain-only-text><span class=secno>12.2.5.2 </span>Parsing elements that contain only text</h5>
+
+  <p>The <dfn id=generic-raw-text-element-parsing-algorithm>generic raw text element parsing algorithm</dfn> and the <dfn id=generic-rcdata-element-parsing-algorithm>generic RCDATA element
   parsing algorithm</dfn> consist of the following steps. These algorithms are always invoked in
   response to a start tag token.</p>
 
@@ -88843,7 +88938,7 @@
    <li><p>Then, switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-incdata title="insertion mode:
    text">text</a>".</li>
 
-  </ol><h5 id=closing-elements-that-have-implied-end-tags><span class=secno>12.2.5.2 </span>Closing elements that have implied end tags</h5>
+  </ol><h5 id=closing-elements-that-have-implied-end-tags><span class=secno>12.2.5.3 </span>Closing elements that have implied end tags</h5>
 
   <p>When the steps below require the UA to <dfn id=generate-implied-end-tags>generate implied end
   tags</dfn>, then, while the <a href=#current-node>current node</a> is a
@@ -88859,48 +88954,7 @@
   above steps as if that element was not in the above list.</p>
 
 
-  <h5 id=foster-parenting><span class=secno>12.2.5.3 </span>Foster parenting</h5>
 
-  <p>Foster parenting happens when content is misnested in tables.</p>
-
-  <p>When a node <var title="">node</var> is to be <dfn id=foster-parent title="foster
-  parent">foster parented</dfn>, the node <var title="">node</var>
-  must be inserted into the <i><a href=#foster-parent-element>foster parent element</a></i>.</p>
-
-  <p class=note>This typically happens as part of the <a href=#insert-an-html-element>insert an HTML element</a>
-  algorithm above: when that algorithm would normally insert the newly created node into the
-  <a href=#current-node>current node</a>, it gets inserted into the <i><a href=#foster-parent-element>foster parent element</a></i> instead.</p>
-
-  <p>The <dfn id=foster-parent-element>foster parent element</dfn> is the parent element of the
-  last <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open
-  elements</a>, if there is a <code><a href=#the-table-element>table</a></code> element and it has
-  such a parent element.</p>
-
-  <p class=note>It might have no parent or some other kind parent if
-  a script manipulated the DOM after the element was inserted by the
-  parser.</p>
-
-  <p>If there is no <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of
-  open elements</a> (<a href=#fragment-case>fragment case</a>), then the
-  <i><a href=#foster-parent-element>foster parent element</a></i> is the first element in the <a href=#stack-of-open-elements>stack
-  of open elements</a> (the <code><a href=#the-html-element>html</a></code> element). Otherwise,
-  if there is a <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open
-  elements</a>, but the last <code><a href=#the-table-element>table</a></code> element in the
-  <a href=#stack-of-open-elements>stack of open elements</a> has no parent, or its parent
-  node is not an element, then the <i><a href=#foster-parent-element>foster parent element</a></i> is the
-  element before the last <code><a href=#the-table-element>table</a></code> element in the
-  <a href=#stack-of-open-elements>stack of open elements</a>.</p>
-
-  <p>If the <i><a href=#foster-parent-element>foster parent element</a></i> is the parent element of the
-  last <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open
-  elements</a>, then <var title="">node</var> must be inserted into
-  the <i><a href=#foster-parent-element>foster parent element</a></i>, immediately <em>before</em> the
-  last <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open
-  elements</a>; otherwise, <var title="">node</var> must be
-  <em>appended</em> to the <i><a href=#foster-parent-element>foster parent element</a></i>.</p>
-
-
-
   <h5 id=parsing-main-inhtml><span class=secno>12.2.5.4 </span>The rules for parsing tokens in HTML content</h5>
 
 
@@ -89193,9 +89247,9 @@
 
    <dt>A comment token</dt>
    <dd>
-    <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <a href=#current-node>current
-    node</a> with the <code title="">data</code> attribute set to
-    the data given in the comment token.</p>
+    <p>Append a <code><a href=#comment-0>Comment</a></code> node with the <code title="">data</code> attribute set to the
+    data given in the comment token <a href=#insert-a-node-in-the-appropriate-place title="insert a node in the appropriate place">in the
+    appropriate place</a>.</p>
    </dd>
 
    <dt>A DOCTYPE token</dt>
@@ -89253,15 +89307,14 @@
    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
    U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
    <dd>
-    <p><a href=#insert-a-character title="insert a character">Insert the character</a> into
-    the <a href=#current-node>current node</a>.</p>
+    <p><a href=#insert-a-character title="insert a character">Insert the character</a>.</p>
    </dd>
 
    <dt>A comment token</dt>
    <dd>
-    <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <a href=#current-node>current
-    node</a> with the <code title="">data</code> attribute set to
-    the data given in the comment token.</p>
+    <p>Append a <code><a href=#comment-0>Comment</a></code> node with the <code title="">data</code> attribute set to the
+    data given in the comment token <a href=#insert-a-node-in-the-appropriate-place title="insert a node in the appropriate place">in the
+    appropriate place</a>.</p>
    </dd>
 
    <dt>A DOCTYPE token</dt>
@@ -89360,9 +89413,8 @@
      <code><a href=#the-script-element>script</a></code> element as <a href=#already-started>"already
      started"</a>. (<a href=#fragment-case>fragment case</a>)</li>
 
-     <li><p>Append the new element to the <a href=#current-node>current node</a>
-     and push it onto the <a href=#stack-of-open-elements>stack of open
-     elements</a>.</li>
+     <li><p><a href=#insert-a-node-in-the-appropriate-place title="insert a node in the appropriate place">Insert the node in the appropriate
+     place</a>, and then push it onto the <a href=#stack-of-open-elements>stack of open elements</a>.</li>
 
      <li><p>Switch the tokenizer to the <a href=#script-data-state>script data
      state</a>.</li>
@@ -89474,15 +89526,14 @@
    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
    U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
    <dd>
-    <p><a href=#insert-a-character title="insert a character">Insert the character</a> into
-    the <a href=#current-node>current node</a>.</p>
+    <p><a href=#insert-a-character title="insert a character">Insert the character</a>.</p>
    </dd>
 
    <dt>A comment token</dt>
    <dd>
-    <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <a href=#current-node>current
-    node</a> with the <code title="">data</code> attribute set to
-    the data given in the comment token.</p>
+    <p>Append a <code><a href=#comment-0>Comment</a></code> node with the <code title="">data</code> attribute set to the
+    data given in the comment token <a href=#insert-a-node-in-the-appropriate-place title="insert a node in the appropriate place">in the
+    appropriate place</a>.</p>
    </dd>
 
    <dt>A DOCTYPE token</dt>
@@ -89583,7 +89634,7 @@
     any.</p>
 
     <p><a href=#insert-a-character title="insert a character">Insert the token's
-    character</a> into the <a href=#current-node>current node</a>.</p>
+    character</a>.</p>
 
    </dd>
 
@@ -89594,7 +89645,7 @@
     any.</p>
 
     <p><a href=#insert-a-character title="insert a character">Insert the token's
-    character</a> into the <a href=#current-node>current node</a>.</p>
+    character</a>.</p>
 
     <p>Set the <a href=#frameset-ok-flag>frameset-ok flag</a> to "not ok".</p>
 
@@ -89602,9 +89653,9 @@
 
    <dt>A comment token</dt>
    <dd>
-    <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <a href=#current-node>current
-    node</a> with the <code title="">data</code> attribute set to
-    the data given in the comment token.</p>
+    <p>Append a <code><a href=#comment-0>Comment</a></code> node with the <code title="">data</code> attribute set to the
+    data given in the comment token <a href=#insert-a-node-in-the-appropriate-place title="insert a node in the appropriate place">in the
+    appropriate place</a>.</p>
    </dd>
 
    <dt>A DOCTYPE token</dt>
@@ -90308,22 +90359,8 @@
 
       </ol></li>
 
-     <li>
+     <li><p>Insert whatever <var title="">last node</var> ended up being in the previous step <a href=#insert-a-node-in-the-appropriate-place title="insert a node in the appropriate place">in the appropriate place</a>, but using <var title="">common ancestor</var> as the <i>override target</i>.</li>
 
-      <p>If the <var title="">common ancestor</var> node is a
-      <code><a href=#the-table-element>table</a></code>, <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-tfoot-element>tfoot</a></code>,
-      <code><a href=#the-thead-element>thead</a></code>, or <code><a href=#the-tr-element>tr</a></code> element, then,
-      <a href=#foster-parent>foster parent</a> whatever <var title="">last
-      node</var> ended up being in the previous step, first removing
-      it from its previous parent node if any.</p>
-
-      <p>Otherwise, append whatever <var title="">last node</var>
-      ended up being in the previous step to the <var title="">common
-      ancestor</var> node, first removing it from its previous parent
-      node if any.</p>
-
-     </li>
-
      <li><p><a href=#create-an-element-for-the-token>Create an element for the token</a> for which the
      <var title="">formatting element</var> was created.</li>
 
@@ -90822,7 +90859,7 @@
    <dd>
 
     <p><a href=#insert-a-character title="insert a character">Insert the token's
-    character</a> into the <a href=#current-node>current node</a>.</p>
+    character</a>.</p>
 
     <p class=note>This can never be a U+0000 NULL character; the
     tokenizer converts those to U+FFFD REPLACEMENT CHARACTER
@@ -90979,9 +91016,9 @@
 
    <dt>A comment token</dt>
    <dd>
-    <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <a href=#current-node>current
-    node</a> with the <code title="">data</code> attribute set to
-    the data given in the comment token.</p>
+    <p>Append a <code><a href=#comment-0>Comment</a></code> node with the <code title="">data</code> attribute set to the
+    data given in the comment token <a href=#insert-a-node-in-the-appropriate-place title="insert a node in the appropriate place">in the
+    appropriate place</a>.</p>
    </dd>
 
    <dt>A DOCTYPE token</dt>
@@ -91143,13 +91180,10 @@
    <dt>Anything else</dt>
    <dd>
 
-    <p><a href=#parse-error>Parse error</a>. Process the token <a href=#using-the-rules-for>using the
-    rules for</a> the "<a href=#parsing-main-inbody title="insertion mode: in body">in
-    body</a>" <a href=#insertion-mode>insertion mode</a>, except that whenever a
-    node would be inserted into the <a href=#current-node>current node</a> when the
-    <a href=#current-node>current node</a> is a <code><a href=#the-table-element>table</a></code>,
-    <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-tfoot-element>tfoot</a></code>, <code><a href=#the-thead-element>thead</a></code>, or
-    <code><a href=#the-tr-element>tr</a></code> element, then it must instead be <a href=#foster-parent title="foster parent">foster parented</a>.</p>
+    <p><a href=#parse-error>Parse error</a>. Enable <a href=#foster-parent title="foster parent">foster parenting</a>, process
+    the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody title="insertion mode: in body">in
+    body</a>" <a href=#insertion-mode>insertion mode</a>, and then disable <a href=#foster-parent title="foster parent">foster
+    parenting</a>.</p>
 
    </dd>
 
@@ -91206,7 +91240,7 @@
 
     <p>Otherwise, <a href=#insert-a-character title="insert a character">insert the
     characters</a> given by the <var><a href=#pending-table-character-tokens>pending table character
-    tokens</a></var> list into the <a href=#current-node>current node</a>.</p> <!--
+    tokens</a></var> list.</p> <!--
     i.e. inter-element whitespace in the table model isn't foster
     parented -->
 
@@ -91283,15 +91317,14 @@
    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
    U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
    <dd>
-    <p><a href=#insert-a-character title="insert a character">Insert the character</a> into
-    the <a href=#current-node>current node</a>.</p>
+    <p><a href=#insert-a-character title="insert a character">Insert the character</a>.</p>
    </dd>
 
    <dt>A comment token</dt>
    <dd>
-    <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <a href=#current-node>current
-    node</a> with the <code title="">data</code> attribute set to
-    the data given in the comment token.</p>
+    <p>Append a <code><a href=#comment-0>Comment</a></code> node with the <code title="">data</code> attribute set to the
+    data given in the comment token <a href=#insert-a-node-in-the-appropriate-place title="insert a node in the appropriate place">in the
+    appropriate place</a>.</p>
    </dd>
 
    <dt>A DOCTYPE token</dt>
@@ -91644,14 +91677,14 @@
    <dt>Any other character token</dt>
    <dd>
     <p><a href=#insert-a-character title="insert a character">Insert the token's
-    character</a> into the <a href=#current-node>current node</a>.</p>
+    character</a>.</p>
    </dd>
 
    <dt>A comment token</dt>
    <dd>
-    <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <a href=#current-node>current
-    node</a> with the <code title="">data</code> attribute set to
-    the data given in the comment token.</p>
+    <p>Append a <code><a href=#comment-0>Comment</a></code> node with the <code title="">data</code> attribute set to the
+    data given in the comment token <a href=#insert-a-node-in-the-appropriate-place title="insert a node in the appropriate place">in the
+    appropriate place</a>.</p>
    </dd>
 
    <dt>A DOCTYPE token</dt>
@@ -91878,15 +91911,14 @@
    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
    U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
    <dd>
-    <p><a href=#insert-a-character title="insert a character">Insert the character</a> into
-    the <a href=#current-node>current node</a>.</p>
+    <p><a href=#insert-a-character title="insert a character">Insert the character</a>.</p>
    </dd>
 
    <dt>A comment token</dt>
    <dd>
-    <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <a href=#current-node>current
-    node</a> with the <code title="">data</code> attribute set to
-    the data given in the comment token.</p>
+    <p>Append a <code><a href=#comment-0>Comment</a></code> node with the <code title="">data</code> attribute set to the
+    data given in the comment token <a href=#insert-a-node-in-the-appropriate-place title="insert a node in the appropriate place">in the
+    appropriate place</a>.</p>
    </dd>
 
    <dt>A DOCTYPE token</dt>
@@ -91971,15 +92003,14 @@
    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
    U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
    <dd>
-    <p><a href=#insert-a-character title="insert a character">Insert the character</a> into
-    the <a href=#current-node>current node</a>.</p>
+    <p><a href=#insert-a-character title="insert a character">Insert the character</a>.</p>
    </dd>
 
    <dt>A comment token</dt>
    <dd>
-    <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <a href=#current-node>current
-    node</a> with the <code title="">data</code> attribute set to
-    the data given in the comment token.</p>
+    <p>Append a <code><a href=#comment-0>Comment</a></code> node with the <code title="">data</code> attribute set to the
+    data given in the comment token <a href=#insert-a-node-in-the-appropriate-place title="insert a node in the appropriate place">in the
+    appropriate place</a>.</p>
    </dd>
 
    <dt>A DOCTYPE token</dt>
@@ -92093,7 +92124,7 @@
    <dd>
 
     <p><a href=#parse-error>Parse error</a>. <a href=#insert-a-character title="insert a character">Insert a U+FFFD REPLACEMENT
-    CHARACTER character</a> into the <a href=#current-node>current node</a>.</p>
+    CHARACTER character</a>.</p>
 
    </dd>
 
@@ -92101,16 +92132,14 @@
    FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
    <dd>
 
-    <p><a href=#insert-a-character title="insert a character">Insert the token's character</a> into the <a href=#current-node>current
-    node</a>.</p>
+    <p><a href=#insert-a-character title="insert a character">Insert the token's character</a>.</p>
 
    </dd>
 
    <dt>Any other character token</dt>
    <dd>
 
-    <p><a href=#insert-a-character title="insert a character">Insert the token's character</a> into the <a href=#current-node>current
-    node</a>.</p>
+    <p><a href=#insert-a-character title="insert a character">Insert the token's character</a>.</p>
 
     <p>Set the <a href=#frameset-ok-flag>frameset-ok flag</a> to "not ok".</p>
 
@@ -92119,7 +92148,9 @@
    <dt>A comment token</dt>
    <dd>
 
-    <p>Append a <code><a href=#comment-0>Comment</a></code> node to the <a href=#current-node>current node</a> with the <code title="">data</code> attribute set to the data given in the comment token.</p>
+    <p>Append a <code><a href=#comment-0>Comment</a></code> node with the <code title="">data</code> attribute set to the
+    data given in the comment token <a href=#insert-a-node-in-the-appropriate-place title="insert a node in the appropriate place">in the
+    appropriate place</a>.</p>
 
    </dd>
 
@@ -93268,7 +93299,6 @@
   listed above.</i></p>
 
 
-
   <h2 id=the-xhtml-syntax><span class=secno>13 </span><dfn id=xhtml>The XHTML syntax</dfn></h2>
 
   <p class=note>This section only describes the rules for XML

Modified: source
===================================================================
--- source	2013-06-24 20:28:46 UTC (rev 7997)
+++ source	2013-06-25 05:37:58 UTC (rev 7998)
@@ -96369,10 +96369,9 @@
    element <var title="">entry</var> was created, to obtain <var
    title="">new element</var>.</li>
 
-   <li>Append <var title="">new element</var> to the <span>current
-   node</span> and push it onto the <span>stack of open
-   elements</span> so that it is the new <span>current
-   node</span>.</li>
+   <li>Insert <var title="">new element</var> <span title="insert a node in the appropriate
+   place">in the appropriate place</span> and push it onto the <span>stack of open elements</span>
+   so that it is the new <span>current node</span>.</li>
 
    <li>Replace the entry for <var title="">entry</var> in the list
    with an entry for <var title="">new element</var>.</li>
@@ -99012,64 +99011,6 @@
    <li>A <code title="">title</code> element in the <span>SVG namespace</span></li>
   </ul>
 
-  <hr>
-
-  <p>When the steps below require the UA to <dfn>insert a character</dfn> into a node, if that node
-  has a child immediately before where the character is to be inserted, and that child is a
-  <code>Text</code> node, then the character must be appended to that <code>Text</code> node;
-  otherwise, a new <code>Text</code> node whose data is just that character must be inserted in the
-  appropriate place.</p>
-
-  <div class="example">
-
-   <p>Here are some sample inputs to the parser and the corresponding number of <code>Text</code>
-   nodes that they result in, assuming a user agent that executes scripts.</p>
-
-   <table>
-    <thead>
-     <tr>
-      <th>Input <th>Number of <code>Text</code> nodes
-    <tbody>
-     <tr>
-      <td><pre>A<script>
-var script = document.getElementsByTagName('script')[0];
-document.body.removeChild(script);
-</script>B</pre>
-      <td>One <code>Text</code> node in the document, containing "AB".
-     <tr>
-      <td><pre>A<script>
-var text = document.createTextNode('B');
-document.body.appendChild(text);
-</script>C</pre>
-      <td>Three <code>Text</code> nodes; "A" before the script, the script's contents, and "BC" after the script (the parser appends to the <code>Text</code> node created by the script).
-     <tr>
-      <td><pre>A<script>
-var text = document.getElementsByTagName('script')[0].firstChild;
-text.data = 'B';
-document.body.appendChild(text);
-</script>C</pre>
-      <td>Two adjacent <code>Text</code> nodes in the document, containing "A" and "BC".
-     <tr>
-      <td><pre>A<table>B<tr>C</tr>D</table></pre>
-      <td>One <code>Text</code> node before the table, containing "ABCD". (This is caused by <span title="foster parent">foster parenting</span>.)
-     <tr>
-      <td><pre>A<table><tr> B</tr> C</table></pre>
-      <td>One <code>Text</code> node before the table, containing "A B C" (A-space-B-space-C). (This is caused by <span title="foster parent">foster parenting</span>.)
-     <tr>
-      <td><pre>A<table><tr> B</tr> </em>C</table></pre>
-      <td>One <code>Text</code> node before the table, containing "A BC" (A-space-B-C), and one <code>Text</code> node inside the table (as a child of a <code>tbody</code>) with a single space character. (Space characters separated from non-space characters by non-character tokens are not affected by <span title="foster parent">foster parenting</span>, even if those other tokens then get ignored.)
-   </table>
-
-  </div>
-
-  <p id="mutation-during-parsing">DOM mutation events must not fire for changes caused by the UA
-  parsing the document. This includes the parsing of any content inserted using <code
-  title="dom-document-write">document.write()</code> and <code
-  title="dom-document-writeln">document.writeln()</code> calls. <a
-  href="#refsDOMEVENTS">[DOMEVENTS]</a></p>
-
-  <p>However, mutation observers <em>do</em> fire, as required by the DOM specification.</p>
-
   <p class="note">Not all of the tag names mentioned below are conformant tag names in this
   specification; many are included to handle legacy content. They still form part of the algorithm
   that implementations are required to implement to claim conformance.</p>
@@ -99081,7 +99022,7 @@
   depth constraints.</p>
 
 
-  <h5>Creating and inserting elements</h5>
+  <h5>Creating and inserting nodes</h5>
 
   <p>When the steps below require the UA to <dfn title="create an element for the token">create an
   element for a token</dfn> in a particular namespace, the UA must create a node implementing the
@@ -99108,25 +99049,33 @@
          https://www.w3.org/Bugs/Public/show_bug.cgi?id=18367
        Not sure what we could call them instead, though... -->
 
-  <p>When the steps below require the UA to <dfn>insert an HTML element</dfn> for a token, the UA
-  must first <span>create an element for the token</span> in the <span>HTML namespace</span>, and
-  then append this node to the <span>current node</span>, and push it onto the <span>stack of open
-  elements</span> so that it is the new <span>current node</span>.</p>
+  <p>When the steps below require the UA to <dfn>insert an HTML element</dfn> for a token,
+  optionally in a specific place, the UA must run the following steps:</p>
 
-  <p>The steps below may also require that the UA insert an HTML element in a particular place, in
-  which case the UA must follow the same steps except that it must insert or append the new node in
-  the location specified instead of appending it to the <span>current node</span>. (This happens in
-  particular during the parsing of tables with invalid content.)</p>
+  <ol>
 
-  <p>If an element created by the <span>insert an HTML element</span> algorithm is a
-  <span>form-associated element</span>, and the <span><code title="">form</code> element
-  pointer</span> is not null, and the newly created element doesn't have a <code
-  title="attr-fae-form">form</code> attribute, the user agent must <span
-  title="concept-form-association">associate</span> the newly created element with the
-  <code>form</code> element pointed to by the <span><code title="">form</code> element
-  pointer</span> when the element is inserted, instead of running the <span>reset the form
-  owner</span> algorithm.</p>
+   <li><p><span>Create an element for the token</span> in the <span>HTML namespace</span>.</p></li>
 
+   <li><p>If the element is a <span>form-associated element</span>, and the <span><code
+   title="">form</code> element pointer</span> is not null, and the newly created element doesn't
+   have a <code title="attr-fae-form">form</code> attribute, <span
+   title="concept-form-association">associate</span> the newly created element with the
+   <code>form</code> element pointed to by the <span><code title="">form</code> element
+   pointer</span>, and suppress the running of the <span>reset the form owner</span> algorithm in
+   the next step.</p></li>
+
+   <li><p>If no specific place has been specified, <span title="insert a node in the appropriate
+   place">insert the node in the appropriate place</span>; otherwise, if a specific place has been
+   specified, insert or append the node as specified.</p></li>
+
+   <li><p>Push the element onto the <span>stack of open elements</span> so that it is the new
+   <span>current node</span>.</p></li>
+
+  </ol>
+
+  <p class="note">A specific place is specified in in particular during the parsing of tables with
+  invalid content.</p>
+
   <hr>
 
   <p>When the steps below require the UA to <dfn>insert a foreign element</dfn> for a token, the UA
@@ -99139,6 +99088,11 @@
   namespace</span> whose value is not the <span>XLink Namespace</span>, that is a <span>parse
   error</span>.</p>
 
+  <p class="note">The <span>insert a foreign element</span> algorithm isn't affected by the <span
+  title="foster parent">foster parenting</span> logic (it doesn't use the <span>insert a node in the
+  appropriate place</span> algorithm); the <span>current node</span>, when the <span>insert a
+  foreign element</span> algorithm is invoked, is always itself a non-HTML element.</p>
+
   <p>When the steps below require the user agent to <dfn>adjust MathML attributes</dfn> for a token,
   then, if the token has an attribute named <code title="">definitionurl</code>, change its name to
   <code title="">definitionURL</code> (note the case difference).</p>
@@ -99245,6 +99199,167 @@
 
   <hr>
 
+  <p>When the steps below require the user agent to <dfn>insert a character</dfn> for a token, the
+  user agent must insert it <span title="insert a node in the appropriate place">in the appropriate
+  place</span>.</p>
+
+  <hr>
+
+  <p>When the user agent is required to <dfn>insert a node in the appropriate place</dfn>,
+  optionally using a particular <i>override target</i>, the user agent must follow the following
+  steps:</p>
+
+  <ol>
+
+   <li>
+
+    <p>If there was an <i>override target</i> specified, then let <var title="">target</var> be the
+    <i>override target</i>.</p>
+
+    <p>Otherwise, let <var title="">target</var> be the <span>current node</span>.</p>
+
+   </li>
+
+   <li>
+
+    <p>Determine the <var title="">adjusted insertion location</var> using the first matching steps
+    from the following list:</p>
+
+    <dl class="switch">
+
+     <dt>If <dfn title="foster parent">foster parenting</dfn> is enabled and <var
+     title="">target</var> is a <code>table</code>, <code>tbody</code>, <code>tfoot</code>,
+     <code>thead</code>, or <code>tr</code> element</dt>
+
+     <dd>
+
+      <p class="note">Foster parenting happens when content is misnested in tables.</p>
+
+      <p>The <dfn>foster parent element</dfn> is the parent element of the last <code>table</code>
+      element in the <span>stack of open elements</span>, if there is a <code>table</code> element and
+      it has such a parent element.</p>
+
+      <p class="note">It might have no parent or some other kind parent if a script manipulated the
+      DOM after the element was inserted by the parser.</p>
+
+      <p>If there is no <code>table</code> element in the <span>stack of open elements</span>
+      (<span>fragment case</span>), then the <i>foster parent element</i> is the first element in the
+      <span>stack of open elements</span> (the <code>html</code> element). Otherwise, if there is a
+      <code>table</code> element in the <span>stack of open elements</span>, but the last
+      <code>table</code> element in the <span>stack of open elements</span> has no parent, or its
+      parent node is not an element, then the <i>foster parent element</i> is the element before the
+      last <code>table</code> element in the <span>stack of open elements</span>.</p>
+
+      <p>If the <i>foster parent element</i> is the parent element of the last <code>table</code>
+      element in the <span>stack of open elements</span>, then the <var title="">adjusted insertion
+      location</var> is inside the <i>foster parent element</i>, immediately <em>before</em> the
+      last <code>table</code> element in the <span>stack of open elements</span>; otherwise, the
+      <var title="">adjusted insertion location</var> is inside the <i>foster parent element</i>,
+      after its last child (if any).</p>
+
+     </dd>
+
+     <dt>Otherwise</dt>
+
+     <dd>
+
+      <p>The <var title="">adjusted insertion location</var> is inside <var title="">target</var>,
+      after its last child (if any).</p>
+
+     </dd>
+
+    </dl>
+
+   </li>
+
+   <li>
+
+    <p>Run the first matching steps from the following list to actually perform the insertion:</p>
+
+    <dl class="switch">
+
+     <dt>If the node being inserted is a character</dt>
+
+     <dd>
+
+      <p>If there is a <code>Text</code> node immediately before the <var title="">adjusted
+      insertion location</var>, then append the character to that <code>Text</code> node.</p>
+
+      <p>Otherwise, create a new <code>Text</code> node whose data is just that character, and
+      insert it at the <var title="">adjusted insertion location</var>.</p>
+
+     </dd>
+
+     <dt>Otherwise</dt>
+
+     <dd>
+
+      <p>Insert the node at the <var title="">adjusted insertion location</var>.</p>
+
+     </dd>
+
+    </dl>
+
+   </li>
+
+  </ol>
+
+  <hr>
+
+  <div class="example">
+
+   <p>Here are some sample inputs to the parser and the corresponding number of <code>Text</code>
+   nodes that they result in, assuming a user agent that executes scripts.</p>
+
+   <table>
+    <thead>
+     <tr>
+      <th>Input <th>Number of <code>Text</code> nodes
+    <tbody>
+     <tr>
+      <td><pre>A<script>
+var script = document.getElementsByTagName('script')[0];
+document.body.removeChild(script);
+</script>B</pre>
+      <td>One <code>Text</code> node in the document, containing "AB".
+     <tr>
+      <td><pre>A<script>
+var text = document.createTextNode('B');
+document.body.appendChild(text);
+</script>C</pre>
+      <td>Three <code>Text</code> nodes; "A" before the script, the script's contents, and "BC" after the script (the parser appends to the <code>Text</code> node created by the script).
+     <tr>
+      <td><pre>A<script>
+var text = document.getElementsByTagName('script')[0].firstChild;
+text.data = 'B';
+document.body.appendChild(text);
+</script>C</pre>
+      <td>Two adjacent <code>Text</code> nodes in the document, containing "A" and "BC".
+     <tr>
+      <td><pre>A<table>B<tr>C</tr>D</table></pre>
+      <td>One <code>Text</code> node before the table, containing "ABCD". (This is caused by <span title="foster parent">foster parenting</span>.)
+     <tr>
+      <td><pre>A<table><tr> B</tr> C</table></pre>
+      <td>One <code>Text</code> node before the table, containing "A B C" (A-space-B-space-C). (This is caused by <span title="foster parent">foster parenting</span>.)
+     <tr>
+      <td><pre>A<table><tr> B</tr> </em>C</table></pre>
+      <td>One <code>Text</code> node before the table, containing "A BC" (A-space-B-C), and one <code>Text</code> node inside the table (as a child of a <code>tbody</code>) with a single space character. (Space characters separated from non-space characters by non-character tokens are not affected by <span title="foster parent">foster parenting</span>, even if those other tokens then get ignored.)
+   </table>
+
+  </div>
+
+  <p id="mutation-during-parsing">DOM mutation events must not fire for changes caused by the UA
+  parsing the document. This includes the parsing of any content inserted using <code
+  title="dom-document-write">document.write()</code> and <code
+  title="dom-document-writeln">document.writeln()</code> calls. <a
+  href="#refsDOMEVENTS">[DOMEVENTS]</a></p>
+
+  <p>However, mutation observers <em>do</em> fire, as required by the DOM specification.</p>
+
+
+
+  <h5>Parsing elements that contain only text</h5>
+
   <p>The <dfn>generic raw text element parsing algorithm</dfn> and the <dfn>generic RCDATA element
   parsing algorithm</dfn> consist of the following steps. These algorithms are always invoked in
   response to a start tag token.</p>
@@ -99267,7 +99382,6 @@
   </ol>
 
 
-
   <h5>Closing elements that have implied end tags</h5>
 
   <p>When the steps below require the UA to <dfn>generate implied end
@@ -99284,48 +99398,7 @@
   above steps as if that element was not in the above list.</p>
 
 
-  <h5>Foster parenting</h5>
 
-  <p>Foster parenting happens when content is misnested in tables.</p>
-
-  <p>When a node <var title="">node</var> is to be <dfn title="foster
-  parent">foster parented</dfn>, the node <var title="">node</var>
-  must be inserted into the <i>foster parent element</i>.</p>
-
-  <p class="note">This typically happens as part of the <span>insert an HTML element</span>
-  algorithm above: when that algorithm would normally insert the newly created node into the
-  <span>current node</span>, it gets inserted into the <i>foster parent element</i> instead.</p>
-
-  <p>The <dfn>foster parent element</dfn> is the parent element of the
-  last <code>table</code> element in the <span>stack of open
-  elements</span>, if there is a <code>table</code> element and it has
-  such a parent element.</p>
-
-  <p class="note">It might have no parent or some other kind parent if
-  a script manipulated the DOM after the element was inserted by the
-  parser.</p>
-
-  <p>If there is no <code>table</code> element in the <span>stack of
-  open elements</span> (<span>fragment case</span>), then the
-  <i>foster parent element</i> is the first element in the <span>stack
-  of open elements</span> (the <code>html</code> element). Otherwise,
-  if there is a <code>table</code> element in the <span>stack of open
-  elements</span>, but the last <code>table</code> element in the
-  <span>stack of open elements</span> has no parent, or its parent
-  node is not an element, then the <i>foster parent element</i> is the
-  element before the last <code>table</code> element in the
-  <span>stack of open elements</span>.</p>
-
-  <p>If the <i>foster parent element</i> is the parent element of the
-  last <code>table</code> element in the <span>stack of open
-  elements</span>, then <var title="">node</var> must be inserted into
-  the <i>foster parent element</i>, immediately <em>before</em> the
-  last <code>table</code> element in the <span>stack of open
-  elements</span>; otherwise, <var title="">node</var> must be
-  <em>appended</em> to the <i>foster parent element</i>.</p>
-
-
-
   <h5 id="parsing-main-inhtml">The rules for parsing tokens in HTML content</h5>
 
 
@@ -99656,9 +99729,9 @@
 
    <dt>A comment token</dt>
    <dd>
-    <p>Append a <code>Comment</code> node to the <span>current
-    node</span> with the <code title="">data</code> attribute set to
-    the data given in the comment token.</p>
+    <p>Append a <code>Comment</code> node with the <code title="">data</code> attribute set to the
+    data given in the comment token <span title="insert a node in the appropriate place">in the
+    appropriate place</span>.</p>
    </dd>
 
    <dt>A DOCTYPE token</dt>
@@ -99723,15 +99796,14 @@
    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
    U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
    <dd>
-    <p><span title="insert a character">Insert the character</span> into
-    the <span>current node</span>.</p>
+    <p><span title="insert a character">Insert the character</span>.</p>
    </dd>
 
    <dt>A comment token</dt>
    <dd>
-    <p>Append a <code>Comment</code> node to the <span>current
-    node</span> with the <code title="">data</code> attribute set to
-    the data given in the comment token.</p>
+    <p>Append a <code>Comment</code> node with the <code title="">data</code> attribute set to the
+    data given in the comment token <span title="insert a node in the appropriate place">in the
+    appropriate place</span>.</p>
    </dd>
 
    <dt>A DOCTYPE token</dt>
@@ -99837,9 +99909,8 @@
      <code>script</code> element as <span>"already
      started"</span>. (<span>fragment case</span>)</p></li>
 
-     <li><p>Append the new element to the <span>current node</span>
-     and push it onto the <span>stack of open
-     elements</span>.</p></li>
+     <li><p><span title="insert a node in the appropriate place">Insert the node in the appropriate
+     place</span>, and then push it onto the <span>stack of open elements</span>.</p></li>
 
      <li><p>Switch the tokenizer to the <span>script data
      state</span>.</p></li>
@@ -99968,15 +100039,14 @@
    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
    U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
    <dd>
-    <p><span title="insert a character">Insert the character</span> into
-    the <span>current node</span>.</p>
+    <p><span title="insert a character">Insert the character</span>.</p>
    </dd>
 
    <dt>A comment token</dt>
    <dd>
-    <p>Append a <code>Comment</code> node to the <span>current
-    node</span> with the <code title="">data</code> attribute set to
-    the data given in the comment token.</p>
+    <p>Append a <code>Comment</code> node with the <code title="">data</code> attribute set to the
+    data given in the comment token <span title="insert a node in the appropriate place">in the
+    appropriate place</span>.</p>
    </dd>
 
    <dt>A DOCTYPE token</dt>
@@ -100088,7 +100158,7 @@
     any.</p>
 
     <p><span title="insert a character">Insert the token's
-    character</span> into the <span>current node</span>.</p>
+    character</span>.</p>
 
    </dd>
 
@@ -100099,7 +100169,7 @@
     any.</p>
 
     <p><span title="insert a character">Insert the token's
-    character</span> into the <span>current node</span>.</p>
+    character</span>.</p>
 
     <p>Set the <span>frameset-ok flag</span> to "not ok".</p>
 
@@ -100107,9 +100177,9 @@
 
    <dt>A comment token</dt>
    <dd>
-    <p>Append a <code>Comment</code> node to the <span>current
-    node</span> with the <code title="">data</code> attribute set to
-    the data given in the comment token.</p>
+    <p>Append a <code>Comment</code> node with the <code title="">data</code> attribute set to the
+    data given in the comment token <span title="insert a node in the appropriate place">in the
+    appropriate place</span>.</p>
    </dd>
 
    <dt>A DOCTYPE token</dt>
@@ -100876,22 +100946,10 @@
 
      </li>
 
-     <li>
+     <li><p>Insert whatever <var title="">last node</var> ended up being in the previous step <span
+     title="insert a node in the appropriate place">in the appropriate place</span>, but using <var
+     title="">common ancestor</var> as the <i>override target</i>.</p></li>
 
-      <p>If the <var title="">common ancestor</var> node is a
-      <code>table</code>, <code>tbody</code>, <code>tfoot</code>,
-      <code>thead</code>, or <code>tr</code> element, then,
-      <span>foster parent</span> whatever <var title="">last
-      node</var> ended up being in the previous step, first removing
-      it from its previous parent node if any.</p>
-
-      <p>Otherwise, append whatever <var title="">last node</var>
-      ended up being in the previous step to the <var title="">common
-      ancestor</var> node, first removing it from its previous parent
-      node if any.</p>
-
-     </li>
-
      <li><p><span>Create an element for the token</span> for which the
      <var title="">formatting element</var> was created.</p></li>
 
@@ -101425,7 +101483,7 @@
    <dd>
 
     <p><span title="insert a character">Insert the token's
-    character</span> into the <span>current node</span>.</p>
+    character</span>.</p>
 
     <p class="note">This can never be a U+0000 NULL character; the
     tokenizer converts those to U+FFFD REPLACEMENT CHARACTER
@@ -101602,9 +101660,9 @@
 
    <dt>A comment token</dt>
    <dd>
-    <p>Append a <code>Comment</code> node to the <span>current
-    node</span> with the <code title="">data</code> attribute set to
-    the data given in the comment token.</p>
+    <p>Append a <code>Comment</code> node with the <code title="">data</code> attribute set to the
+    data given in the comment token <span title="insert a node in the appropriate place">in the
+    appropriate place</span>.</p>
    </dd>
 
    <dt>A DOCTYPE token</dt>
@@ -101772,14 +101830,10 @@
    <dt>Anything else</dt>
    <dd>
 
-    <p><span>Parse error</span>. Process the token <span>using the
-    rules for</span> the "<span title="insertion mode: in body">in
-    body</span>" <span>insertion mode</span>, except that whenever a
-    node would be inserted into the <span>current node</span> when the
-    <span>current node</span> is a <code>table</code>,
-    <code>tbody</code>, <code>tfoot</code>, <code>thead</code>, or
-    <code>tr</code> element, then it must instead be <span
-    title="foster parent">foster parented</span>.</p>
+    <p><span>Parse error</span>. Enable <span title="foster parent">foster parenting</span>, process
+    the token <span>using the rules for</span> the "<span title="insertion mode: in body">in
+    body</span>" <span>insertion mode</span>, and then disable <span title="foster parent">foster
+    parenting</span>.</p>
 
    </dd>
 
@@ -101841,7 +101895,7 @@
 
     <p>Otherwise, <span title="insert a character">insert the
     characters</span> given by the <var>pending table character
-    tokens</var> list into the <span>current node</span>.</p> <!--
+    tokens</var> list.</p> <!--
     i.e. inter-element whitespace in the table model isn't foster
     parented -->
 
@@ -101931,15 +101985,14 @@
    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
    U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
    <dd>
-    <p><span title="insert a character">Insert the character</span> into
-    the <span>current node</span>.</p>
+    <p><span title="insert a character">Insert the character</span>.</p>
    </dd>
 
    <dt>A comment token</dt>
    <dd>
-    <p>Append a <code>Comment</code> node to the <span>current
-    node</span> with the <code title="">data</code> attribute set to
-    the data given in the comment token.</p>
+    <p>Append a <code>Comment</code> node with the <code title="">data</code> attribute set to the
+    data given in the comment token <span title="insert a node in the appropriate place">in the
+    appropriate place</span>.</p>
    </dd>
 
    <dt>A DOCTYPE token</dt>
@@ -102326,14 +102379,14 @@
    <dt>Any other character token</dt>
    <dd>
     <p><span title="insert a character">Insert the token's
-    character</span> into the <span>current node</span>.</p>
+    character</span>.</p>
    </dd>
 
    <dt>A comment token</dt>
    <dd>
-    <p>Append a <code>Comment</code> node to the <span>current
-    node</span> with the <code title="">data</code> attribute set to
-    the data given in the comment token.</p>
+    <p>Append a <code>Comment</code> node with the <code title="">data</code> attribute set to the
+    data given in the comment token <span title="insert a node in the appropriate place">in the
+    appropriate place</span>.</p>
    </dd>
 
    <dt>A DOCTYPE token</dt>
@@ -102584,15 +102637,14 @@
    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
    U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
    <dd>
-    <p><span title="insert a character">Insert the character</span> into
-    the <span>current node</span>.</p>
+    <p><span title="insert a character">Insert the character</span>.</p>
    </dd>
 
    <dt>A comment token</dt>
    <dd>
-    <p>Append a <code>Comment</code> node to the <span>current
-    node</span> with the <code title="">data</code> attribute set to
-    the data given in the comment token.</p>
+    <p>Append a <code>Comment</code> node with the <code title="">data</code> attribute set to the
+    data given in the comment token <span title="insert a node in the appropriate place">in the
+    appropriate place</span>.</p>
    </dd>
 
    <dt>A DOCTYPE token</dt>
@@ -102685,15 +102737,14 @@
    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
    U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
    <dd>
-    <p><span title="insert a character">Insert the character</span> into
-    the <span>current node</span>.</p>
+    <p><span title="insert a character">Insert the character</span>.</p>
    </dd>
 
    <dt>A comment token</dt>
    <dd>
-    <p>Append a <code>Comment</code> node to the <span>current
-    node</span> with the <code title="">data</code> attribute set to
-    the data given in the comment token.</p>
+    <p>Append a <code>Comment</code> node with the <code title="">data</code> attribute set to the
+    data given in the comment token <span title="insert a node in the appropriate place">in the
+    appropriate place</span>.</p>
    </dd>
 
    <dt>A DOCTYPE token</dt>
@@ -102829,7 +102880,7 @@
    <dd>
 
     <p><span>Parse error</span>. <span title="insert a character">Insert a U+FFFD REPLACEMENT
-    CHARACTER character</span> into the <span>current node</span>.</p>
+    CHARACTER character</span>.</p>
 
    </dd>
 
@@ -102837,16 +102888,14 @@
    FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
    <dd>
 
-    <p><span title="insert a character">Insert the token's character</span> into the <span>current
-    node</span>.</p>
+    <p><span title="insert a character">Insert the token's character</span>.</p>
 
    </dd>
 
    <dt>Any other character token</dt>
    <dd>
 
-    <p><span title="insert a character">Insert the token's character</span> into the <span>current
-    node</span>.</p>
+    <p><span title="insert a character">Insert the token's character</span>.</p>
 
     <p>Set the <span>frameset-ok flag</span> to "not ok".</p>
 
@@ -102855,8 +102904,9 @@
    <dt>A comment token</dt>
    <dd>
 
-    <p>Append a <code>Comment</code> node to the <span>current node</span> with the <code
-    title="">data</code> attribute set to the data given in the comment token.</p>
+    <p>Append a <code>Comment</code> node with the <code title="">data</code> attribute set to the
+    data given in the comment token <span title="insert a node in the appropriate place">in the
+    appropriate place</span>.</p>
 
    </dd>
 
@@ -104191,7 +104241,6 @@
   listed above.</i></p>
 
 
-
   <h2><dfn id="xhtml">The XHTML syntax</dfn></h2>
 
   <p class="note">This section only describes the rules for XML




More information about the Commit-Watchers mailing list