Permalink
Browse files

[] (0) Make outerHTML and insertAdjacentHTML work on XML too. Reorgan…

…ise things and define the interaction of XML and the DOM for the purposes of HTML APIs.

git-svn-id: http://svn.whatwg.org/webapps@2720 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information...
1 parent f299e41 commit b94438839d712987c2a22ea09614fa35992659d7 @Hixie Hixie committed Jan 29, 2009
Showing with 958 additions and 952 deletions.
  1. +474 −453 index
  2. +484 −499 source
View
927 index
@@ -33,7 +33,7 @@
<div class=head>
<p><a class=logo href=http://www.whatwg.org/ rel=home><img alt=WHATWG src=/images/logo></a></p>
<h1>HTML 5</h1>
- <h2 class="no-num no-toc" id=draft-recommendation-&mdash;-date:-01-jan-1901>Draft Recommendation &mdash; 28 January 2009</h2>
+ <h2 class="no-num no-toc" id=draft-recommendation-&mdash;-date:-01-jan-1901>Draft Recommendation &mdash; 29 January 2009</h2>
<p>You can take part in this work. <a href=http://www.whatwg.org/mailing-list>Join the working group's discussion list.</a></p>
<p><strong>Web designers!</strong> We have a <a href=http://blog.whatwg.org/faq/>FAQ</a>, a <a href=http://forums.whatwg.org/>forum</a>, and a <a href=http://www.whatwg.org/mailing-list#help>help mailing list</a> for you!</p>
<dl><dt>Multiple-page version:</dt>
@@ -331,8 +331,11 @@
<li><a href=#dynamic-markup-insertion><span class=secno>3.7 </span>Dynamic markup insertion</a>
<ol>
<li><a href=#controlling-the-input-stream><span class=secno>3.7.1 </span>Controlling the input stream</a></li>
- <li><a href=#dynamic-markup-insertion-in-html><span class=secno>3.7.2 </span>Dynamic markup insertion in HTML</a></li>
- <li><a href=#dynamic-markup-insertion-in-xml><span class=secno>3.7.3 </span>Dynamic markup insertion in XML</a></ol></ol></li>
+ <li><a href=#document.write()><span class=secno>3.7.2 </span><code title=dom-document-write>document.write()</code></a></li>
+ <li><a href=#document.writeln()><span class=secno>3.7.3 </span><code title=dom-document-writeln>document.writeln()</code></a></li>
+ <li><a href=#innerhtml><span class=secno>3.7.4 </span><code title=dom-innerHTML>innerHTML</code></a></li>
+ <li><a href=#outerhtml><span class=secno>3.7.5 </span><code title=dom-outerHTML>outerHTML</code></a></li>
+ <li><a href=#insertadjacenthtml()><span class=secno>3.7.6 </span><code title=dom-insertAdjacentHTML>insertAdjacentHTML()</code></a></ol></ol></li>
<li><a href=#semantics><span class=secno>4 </span>The elements of HTML</a>
<ol>
<li><a href=#the-root-element><span class=secno>4.1 </span>The root element</a>
@@ -1014,27 +1017,33 @@
<li><a href=#serializing-html-fragments><span class=secno>8.4 </span>Serializing HTML fragments</a></li>
<li><a href=#parsing-html-fragments><span class=secno>8.5 </span>Parsing HTML fragments</a></li>
<li><a href=#named-character-references><span class=secno>8.6 </span>Named character references</a></ol></li>
- <li><a href=#rendering><span class=secno>9 </span>Rendering</a>
+ <li><a href=#the-xhtml-syntax><span class=secno>9 </span>The XHTML syntax</a>
<ol>
- <li><a href=#rendering-and-menus/toolbars><span class=secno>9.1 </span>Rendering and menus/toolbars</a>
+ <li><a href=#writing-xhtml-documents><span class=secno>9.1 </span>Writing XHTML documents</a></li>
+ <li><a href=#parsing-xhtml-documents><span class=secno>9.2 </span>Parsing XHTML documents</a></li>
+ <li><a href=#serializing-xhtml-fragments><span class=secno>9.3 </span>Serializing XHTML fragments</a></li>
+ <li><a href=#parsing-xhtml-fragments><span class=secno>9.4 </span>Parsing XHTML fragments</a></ol></li>
+ <li><a href=#rendering><span class=secno>10 </span>Rendering</a>
+ <ol>
+ <li><a href=#rendering-and-menus/toolbars><span class=secno>10.1 </span>Rendering and menus/toolbars</a>
<ol>
- <li><a href="#the-'icon'-property"><span class=secno>9.1.1 </span>The 'icon' property</a></ol></ol></li>
- <li><a href=#obsolete-features><span class=secno>10 </span>Obsolete features</a>
+ <li><a href="#the-'icon'-property"><span class=secno>10.1.1 </span>The 'icon' property</a></ol></ol></li>
+ <li><a href=#obsolete-features><span class=secno>11 </span>Obsolete features</a>
<ol>
- <li><a href=#obsolete-elements><span class=secno>10.1 </span>Obsolete elements</a>
+ <li><a href=#obsolete-elements><span class=secno>11.1 </span>Obsolete elements</a>
<ol>
- <li><a href=#the-body-element-0><span class=secno>10.1.1 </span>The <code>body</code> element</a></li>
- <li><a href=#the-applet-element><span class=secno>10.1.2 </span>The <code>applet</code> element</a></ol></li>
- <li><a href=#conformance-checkers-0><span class=secno>10.2 </span>Conformance checkers</a></ol></li>
- <li><a href=#no><span class=secno>11 </span>Things that you can't do with this specification because
+ <li><a href=#the-body-element-0><span class=secno>11.1.1 </span>The <code>body</code> element</a></li>
+ <li><a href=#the-applet-element><span class=secno>11.1.2 </span>The <code>applet</code> element</a></ol></li>
+ <li><a href=#conformance-checkers-0><span class=secno>11.2 </span>Conformance checkers</a></ol></li>
+ <li><a href=#no><span class=secno>12 </span>Things that you can't do with this specification because
they are better handled using other technologies that are further
described herein</a>
<ol>
- <li><a href=#localization><span class=secno>11.1 </span>Localization</a></li>
- <li><a href=#declarative-2d-vector-graphics-and-animation><span class=secno>11.2 </span>Declarative 2D vector graphics and animation</a></li>
- <li><a href=#declarative-3d-scenes><span class=secno>11.3 </span>Declarative 3D scenes</a></li>
- <li><a href=#timers><span class=secno>11.4 </span>Timers</a></li>
- <li><a href=#rendering-and-the-dom><span class=secno>11.5 </span>Rendering and the DOM</a></ol></li>
+ <li><a href=#localization><span class=secno>12.1 </span>Localization</a></li>
+ <li><a href=#declarative-2d-vector-graphics-and-animation><span class=secno>12.2 </span>Declarative 2D vector graphics and animation</a></li>
+ <li><a href=#declarative-3d-scenes><span class=secno>12.3 </span>Declarative 3D scenes</a></li>
+ <li><a href=#timers><span class=secno>12.4 </span>Timers</a></li>
+ <li><a href=#rendering-and-the-dom><span class=secno>12.5 </span>Rendering and the DOM</a></ol></li>
<li><a class=no-num href=#index>Index</a></li>
<li><a class=no-num href=#references>References</a></li>
<li><a class=no-num href=#acknowledgements>Acknowledgements</a></ol>
@@ -1408,7 +1417,7 @@
<p>The term <a href=#html-documents>HTML documents</a> is sometimes used in
contrast with <a href=#xml-documents>XML documents</a> to specifically mean
documents that were parsed using an <a href=#html-parser>HTML parser</a> (as
- opposed to using an <span>XML parser</span> or created purely
+ opposed to using an <a href=#xml-parser>XML parser</a> or created purely
through the DOM).</p>
<p>Generally, when the specification states that a feature applies
@@ -6172,21 +6181,13 @@ interface <dfn id=htmldocument>HTMLDocument</dfn> {
<code>Document</code> object is created, it must have its
<a href=#current-document-readiness>current document readiness</a> set to the string "loading"
if the document is associated with an <a href=#html-parser>HTML parser</a> or an
- <span>XML parser</span>, or to the string "complete"
+ <a href=#xml-parser>XML parser</a>, or to the string "complete"
otherwise. Various algorithms during page loading affect this
value. When the value is set, the user agent must <a href=#fire-a-simple-event>fire a
simple event</a> called <code title=event-readystatechange>readystatechange</code> at the
<code>Document</code> object.</p> <!-- XXX define
document.onreadystatechange -->
- <p>When a <code>Document</code> is created by an <span>XML
- parser</span>, the <a href=#current-document-readiness>current document readiness</a> must be
- changed to "complete" when the parser reaches the end of its input
- stream.</p> <!-- XXX this should be in its own section, and we
- should define 'delay the load event' for XML parsing so that we can
- have the "interactive" state here too. also, XML parser will need to
- fire the /pending state object/, and the 'load' event, and... -->
-
<p>The <dfn id=dom-document-readystate title=dom-document-readyState><code>readyState</code></dfn> DOM
attribute must, on getting, return the <a href=#current-document-readiness>current document
readiness</a>.</p>
@@ -7691,44 +7692,16 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0
</dl><h3 id=dynamic-markup-insertion><span class=secno>3.7 </span><dfn>Dynamic markup insertion</dfn></h3>
- <p>APIs for dynamically inserting markup into the document interact
- with the parser, and thus their behavior varies depending on whether
- they are used with <a href=#html-documents>HTML documents</a> (and the <a href=#html-parser>HTML
- parser</a>) or XHTML in <a href=#xml-documents>XML documents</a> (and the
- <span>XML parser</span><!-- XXX xref -->). The following table
- cross-references the various versions of these APIs.</p>
-
- <table><thead><tr><td></td>
- <th>For documents that are <a href=#html-documents>HTML documents</a></th>
- <th>For documents that are <a href=#xml-documents>XML documents</a></th>
- <tbody><tr><th><code>document.open()</code></th>
- <td colspan=2><a href=#dom-document-open title=dom-document-open><code>document.open()</code></a></td>
- <tr><th><dfn id=dom-document-write title=dom-document-write><code>document.write()</code></dfn></th>
- <td><a href=#dom-document-write-html title=dom-document-write-HTML><code>document.write()</code> in HTML</a></td>
- <td><a href=#dom-document-write-xml title=dom-document-write-XML>not supported</a></td>
- <tr><th><dfn id=dom-innerhtml title=dom-innerHTML><code>innerHTML</code></dfn></th>
- <td><a href=#dom-innerhtml-html title=dom-innerHTML-HTML><code>innerHTML</code> in HTML</a></td>
- <td><a href=#dom-innerhtml-xml title=dom-innerHTML-XML><code>innerHTML</code> in XML</a></td>
- <tr><th><dfn id=dom-outerhtml title=dom-outerHTML><code>outerHTML</code></dfn></th>
- <td><a href=#dom-outerhtml-html title=dom-outerHTML-HTML><code>outerHTML</code> in HTML</a></td>
- <td><a href=#dom-outerhtml-xml title=dom-outerHTML-XML>not supported</a></td>
- <tr><th><dfn id=dom-insertadjacenthtml title=dom-insertAdjacentHTML><code>insertAdjacentHTML()</code></dfn></th>
- <td><a href=#dom-insertadjacenthtml-html title=dom-insertAdjacentHTML-HTML><code>insertAdjacentHTML()</code> in HTML</a></td>
- <td><a href=#dom-insertadjacenthtml-xml title=dom-insertAdjacentHTML-XML>not supported</a></td>
- </table><p>Regardless of the parsing mode, the <dfn id=dom-document-writeln title=dom-document-writeln><code>document.writeln(...)</code></dfn>
- method must call the <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code> method with the
- same argument(s), plus an extra argument consisting of a string
- containing a single line feed character (U+000A).</p>
-
- <p class=note>The <code title=dom-innerHTML><a href=#dom-innerhtml>innerHTML</a></code>
- attribute applies to both <code>Element</code> nodes as well as
- <code>Document</code> nodes. The <code title=dom-outerHTML><a href=#dom-outerhtml>outerHTML</a></code> and <code title=dom-insertAdjacentHTML><a href=#dom-insertadjacenthtml>insertAdjacentHTML()</a></code> members,
- on the other hand, only apply to <code>Element</code> nodes.</p>
+ <p class=note>APIs for dynamically inserting markup into the
+ document interact with the parser, and thus their behavior, varies
+ depending on whether they are used with <a href=#html-documents>HTML documents</a>
+ (and the <a href=#html-parser>HTML parser</a>) or XHTML in <a href=#xml-documents>XML
+ documents</a> (and the <a href=#xml-parser>XML parser</a>).</p>
+
+ <!-- XXX must make sure we spec that innerHTML et al causes mutation
+ events to fire, but document.write() doesn't. (the latter is already
+ req-stated in the parser section, btw) -->
- <p class=note>When inserted using the <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code> method,
- <code><a href=#script>script</a></code> elements execute (typically synchronously), but
- when inserted using <code title=dom-innerHTML-HTML><a href=#dom-innerhtml-html>innerHTML</a></code> and <code title=dom-outerHTML-HTML><a href=#dom-outerhtml-html>outerHTML</a></code> attributes, they do not
- execute at all.</p>
<h4 id=controlling-the-input-stream><span class=secno>3.7.1 </span>Controlling the input stream</h4>
@@ -7886,13 +7859,28 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0
<a href=#the-input-stream>input stream</a>.</p>
- <h4 id=dynamic-markup-insertion-in-html><span class=secno>3.7.2 </span>Dynamic markup insertion in HTML</h4>
- <p>In HTML, the <dfn id=dom-document-write-html title=dom-document-write-HTML><code>document.write(...)</code></dfn>
+
+ <h4 id=document.write()><span class=secno>3.7.2 </span><code title=dom-document-write><a href=#dom-document-write>document.write()</a></code></h4>
+
+ <p>The <dfn id=dom-document-write title=dom-document-write><code>document.write(...)</code></dfn>
method must act as follows:</p>
<ol><li>
+ <p>If the method was invoked on an <a href=#xml-documents title="XML documents">XML
+ document</a>, throw an <code><a href=#invalid_access_err>INVALID_ACCESS_ERR</a></code>
+ exception and abort these steps.</p>
+
+ <!--
+ Where would document.write() insert?
+ Consider: data:text/xml,<script xmlns="http://www.w3.org/1999/xhtml"><![CDATA[ document.write('<foo>Test</foo>'); ]]></script>
+ -->
+
+ </li>
+
+ <li>
+
<p>If the <a href=#insertion-point>insertion point</a> is undefined, the <code title=dom-document-open><a href=#dom-document-open>open()</a></code> method must be called
(with no arguments) on the <code title=Document>document</code>
object. If the user <a href=#refused-to-allow-the-document-to-be-unloaded>refused to allow the document to be
@@ -7928,7 +7916,7 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0
tree construction stage (this can happen if a <code><a href=#script>script</a></code>
end tag token is emitted by the tokeniser).
- <p class=note>If the <code title=dom-document-write-HTML><a href=#dom-document-write-html>document.write()</a></code> method was
+ <p class=note>If the <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code> method was
called from script executing inline (i.e. executing because the
parser parsed a set of <code><a href=#script>script</a></code> tags), then this is a
<a href=#nestedParsing>reentrant invocation of the
@@ -7942,92 +7930,79 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0
</li>
- </ol><hr><p>On getting, the <dfn id=dom-innerhtml-html title=dom-innerHTML-HTML><code>innerHTML</code></dfn> DOM
- attribute must return the result of running the <a href=#html-fragment-serialization-algorithm>HTML fragment
- serialization algorithm</a> on the node.</p>
-
- <p>On setting, <strong>if the node is a document</strong>, the <code title=dom-innerHTML-HTML><a href=#dom-innerhtml-html>innerHTML</a></code> DOM attribute must run
- the following algorithm:</p>
+ </ol><h4 id=document.writeln()><span class=secno>3.7.3 </span><code title=dom-document-writeln><a href=#dom-document-writeln>document.writeln()</a></code></h4>
- <ol><li>
+ <p>The <dfn id=dom-document-writeln title=dom-document-writeln><code>document.writeln(...)</code></dfn>
+ method, when invoked, must act as if the <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code> method had been
+ invoked with the same argument(s), plus an extra argument consisting
+ of a string containing a single line feed character (U+000A).</p>
- <p>If the document has an <span>active parser</span><!--XXX
- xref-->, then stop that parser, and throw away any pending content
- in the input stream. <span class=XXX>what about if it
- doesn't, because it's either like a text/plain, or Atom, or PDF,
- or XHTML, or image document, or something?</span></p><!-- XXX see
- also document.open() -->
- </li>
- <li>
- <p>Remove the children nodes of the <code>Document</code> whose
- <code title=dom-innerHTML-HTML><a href=#dom-innerhtml-html>innerHTML</a></code> attribute is
- being set.</p>
+ <h4 id=innerhtml><span class=secno>3.7.4 </span><code title=dom-innerHTML><a href=#dom-innerhtml>innerHTML</a></code></h4>
- </li>
+ <p>The <dfn id=dom-innerhtml title=dom-innerHTML><code>innerHTML</code></dfn> DOM
+ attribute represents the markup of the node's contents.</p>
- <li>
+ <p>On getting, if the node's document is an <a href=#html-documents title="HTML
+ documents">HTML document</a>, then the attribute must return the
+ result of running the <a href=#html-fragment-serialization-algorithm>HTML fragment serialization
+ algorithm</a> on the node; otherwise, the node's document is an
+ <a href=#xml-documents title="XML documents">XML document</a>, and the attribute
+ must return the result of running the <a href=#xml-fragment-serialization-algorithm>XML fragment
+ serialization algorithm</a> on the node instead (this might raise
+ an exception instead of returning a string).</p>
- <p>Create a new <a href=#html-parser>HTML parser</a>, in its initial state,
- and associate it with the <code>Document</code> node.</p>
+ <p>On setting, the following steps must be run:</p>
- </li>
+ <ol><li>
-<!-- redundant, the document is forcibly already so labeled if we get here
- <li>
+ <p>If the node's document is an <a href=#html-documents title="HTML documents">HTML
+ document</a>: Invoke the <a href=#html-fragment-parsing-algorithm>HTML fragment parsing
+ algorithm</a>.</p>
- <p>Mark the <code>Document</code> object as being an <span
- title="HTML documents">HTML document</span>.</p>
+ <p>If the node's document is an <a href=#xml-documents title="XML documents">XML
+ document</a>: Invoke the <a href=#xml-fragment-parsing-algorithm>XML fragment parsing
+ algorithm</a>.</p>
- </li>
--->
+ <p>In either case, the algorithm must be invoked with the string
+ being assigned into the <code title=dom-innerHTML><a href=#dom-innerhtml>innerHTML</a></code> attribute as the <var title="">input</var>. If the node is an <code>Element</code>
+ node, then, in addition, that element must be passed as the <var title="">context</var> element.</p>
- <li>
+ <p>If this raises an exception, then abort these steps.</p>
- <p>Place into the <a href=#the-input-stream>input stream</a> for the <a href=#html-parser>HTML
- parser</a> just created the string being assigned into the
- <code title=dom-innerHTML-HTML><a href=#dom-innerhtml-html>innerHTML</a></code> attribute.</p>
+ <p>Otherwise, let <var title="">new children</var> be the nodes
+ returned.</p>
</li>
<li>
- <p>Start the parser and let it run until it has consumed all the
- characters just inserted into the input stream. (The
- <code>Document</code> node will have been populated with elements
- and a <code title=event-load><a href=#event-load>load</a></code> event will have fired
- on its <a href=#browsing-context>browsing context</a>'s <code><a href=#window>Window</a></code>
- object.)</p>
-
- </li>
-
- </ol><p>Otherwise, if the node is an element, then setting the <code title=dom-innerHTML-HTML><a href=#dom-innerhtml-html>innerHTML</a></code> DOM attribute must cause
- the following algorithm to run instead:</p>
-
- <ol><li>
+ <p>If the attribute is being set on a <code>Document</code> node,
+ and that document has an active <a href=#html-parser>HTML parser</a> or
+ <a href=#xml-parser>XML parser</a>, then stop that parser.</p>
- <p>Invoke the <a href=#html-fragment-parsing-algorithm>HTML fragment parsing algorithm</a>, with
- the element whose <code title=dom-innerHTML-HTML><a href=#dom-innerhtml-html>innerHTML</a></code> attribute is being set
- as the <var title="">context</var> element, and the string being
- assigned into the <code title=dom-innerHTML-HTML><a href=#dom-innerhtml-html>innerHTML</a></code> attribute as the <var title="">input</var>. Let <var title="">new children</var> be the
- result of this algorithm.</p>
+ <p class=XXX>what about if it doesn't, because it's either
+ like a text/plain, or Atom, or PDF, or XHTML, or image document,
+ or something?</p><!-- XXX see also document.open() -->
</li>
<li>
- <p>Remove the children of the element whose <code title=dom-innerHTML-HTML><a href=#dom-innerhtml-html>innerHTML</a></code> attribute is being
- set, without firing any mutation events.</p>
+ <p>Remove the child nodes of the node whose <code title=dom-innerHTML><a href=#dom-innerhtml>innerHTML</a></code> attribute is being set.</p>
</li>
<li>
- <p>Let <var title="">target document</var> be the <code title="">ownerDocument</code> of the <code>Element</code> node
- whose <code title=dom-innerHTML-HTML><a href=#dom-innerhtml-html>innerHTML</a></code> attribute
- is being set.</p>
+ <p>If the attribute is being set on a <code>Document</code>
+ node, let <var title="">target document</var> be that
+ <code>Document</code> node. Otherwise, the attribute is being
+ set on an <code>Element</code> node; let <var title="">target
+ document</var> be the <code title="">ownerDocument</code> of
+ that <code>Element</code>.</p>
</li>
@@ -8042,23 +8017,32 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0
<li>
<p>Append all the <var title="">new children</var> nodes to the
- node whose <code title=dom-innerHTML-HTML><a href=#dom-innerhtml-html>innerHTML</a></code>
- attribute is being set, preserving their order, without firing any
- mutation events.</p>
+ node whose <code title=dom-innerHTML><a href=#dom-innerhtml>innerHTML</a></code> attribute
+ is being set, preserving their order, without firing any mutation
+ events.</p>
</li>
- </ol><hr><p>On getting, the <dfn id=dom-outerhtml-html title=dom-outerHTML-HTML><code>outerHTML</code></dfn> DOM
- attribute must return the result of running the <a href=#html-fragment-serialization-algorithm>HTML fragment
- serialization algorithm</a> on a fictional node whose only child
- is the node on which the attribute was invoked.</p>
+ </ol><h4 id=outerhtml><span class=secno>3.7.5 </span><code title=dom-outerHTML><a href=#dom-outerhtml>outerHTML</a></code></h4>
+
+ <p>The <dfn id=dom-outerhtml title=dom-outerHTML><code>outerHTML</code></dfn> DOM
+ attribute represents the markup of the element and its contents.</p>
- <p>On setting, the <code title=dom-outerHTML-HTML><a href=#dom-outerhtml-html>outerHTML</a></code>
- DOM attribute must cause the following algorithm to run:</p>
+ <p>On getting, if the node's document is an <a href=#html-documents title="HTML
+ documents">HTML document</a>, then the attribute must return the
+ result of running the <a href=#html-fragment-serialization-algorithm>HTML fragment serialization
+ algorithm</a> on a fictional node whose only child is the node on
+ which the attribute was invoked; otherwise, the node's document is
+ an <a href=#xml-documents title="XML documents">XML document</a>, and the
+ attribute must return the result of running the <a href=#xml-fragment-serialization-algorithm>XML fragment
+ serialization algorithm</a> on that fictional node instead (this
+ might raise an exception instead of returning a string).</p>
+
+ <p>On setting, the following steps must be run:</p>
<ol><li>
- <p>Let <var title="">target</var> be the element whose <code title=dom-innerHTML-HTML><a href=#dom-innerhtml-html>outerHTML</a></code> attribute is being
+ <p>Let <var title="">target</var> be the element whose <code title=dom-outerHTML><a href=#dom-outerhtml>outerHTML</a></code> attribute is being
set.</p>
</li>
@@ -8091,24 +8075,27 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0
<li>
- <p>Invoke the <a href=#html-fragment-parsing-algorithm>HTML fragment parsing algorithm</a>, with
- <var title="">parent</var> as the <var title="">context</var>
- element and the string being assigned into the <code title=dom-outerHTML-HTML><a href=#dom-outerhtml-html>outerHTML</a></code> attribute as the <var title="">input</var>. Let <var title="">new children</var> be the
- result of this algorithm.</p>
+ <p>If <var title="">target</var>'s document is an <a href=#html-documents title="HTML documents">HTML document</a>: Invoke the <a href=#html-fragment-parsing-algorithm>HTML
+ fragment parsing algorithm</a>.</p>
- </li>
+ <p>If <var title="">target</var>'s document is an <a href=#xml-documents title="XML
+ documents">XML document</a>: Invoke the <a href=#xml-fragment-parsing-algorithm>XML fragment
+ parsing algorithm</a>.</p>
- <li>
+ <p>In either case, the algorithm must be invoked with the string
+ being assigned into the <code title=dom-outerHTML><a href=#dom-outerhtml>outerHTML</a></code> attribute as the <var title="">input</var>, and <var title="">parent</var> as the <var title="">context</var> element.</p>
+
+ <p>If this raises an exception, then abort these steps.</p>
- <p>Let <var title="">target document</var> be the <code title="">ownerDocument</code> of <var title="">target</var>.</p>
+ <p>Otherwise, let <var title="">new children</var> be <var title="">target</var>s returned.</p>
</li>
<li>
<p>Set the <code title="">ownerDocument</code> of all the nodes in
- <var title="">new children</var> to the <var title="">target
- document</var>.</p>
+ <var title="">new children</var> to <var title="">target</var>'s
+ document.</p>
</li>
@@ -8121,8 +8108,10 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0
</li>
- </ol><hr><p>The <dfn id=dom-insertadjacenthtml-html title=dom-insertAdjacentHTML-HTML><code>insertAdjacentHTML(<var title="">position</var>, <var title="">text</var>)</code></dfn>
- method, when invoked, must run the following steps:</p>
+ </ol><h4 id=insertadjacenthtml()><span class=secno>3.7.6 </span><code title=dom-insertAdjacentHTML><a href=#dom-insertadjacenthtml>insertAdjacentHTML()</a></code></h4>
+
+ <p>The <dfn id=dom-insertadjacenthtml title=dom-insertAdjacentHTML><code>insertAdjacentHTML(<var title="">position</var>, <var title="">text</var>)</code></dfn>
+ method, when invoked, must run the following algorithm:</p>
<ol><li>
@@ -8185,25 +8174,27 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0
<li>
- <p>Invoke the <a href=#html-fragment-parsing-algorithm>HTML fragment parsing algorithm</a>, with
- the <var title="">context</var> element being that selected by the
- previous step, and <var title="">input</var> being the method's
- <var title="">text</var> argument. Let <var title="">new
- children</var> be the result of this algorithm.</p>
+ <p>If <var title="">target</var>'s document is an <a href=#html-documents title="HTML documents">HTML document</a>: Invoke the <a href=#html-fragment-parsing-algorithm>HTML
+ fragment parsing algorithm</a>.</p>
- </li>
+ <p>If <var title="">target</var>'s document is an <a href=#xml-documents title="XML
+ documents">XML document</a>: Invoke the <a href=#xml-fragment-parsing-algorithm>XML fragment
+ parsing algorithm</a>.</p>
- <li>
+ <p>In either case, the algorithm must be invoked with <var title="">text</var> as the <var title="">input</var>, and the
+ element selected in by the previous step as the <var title="">context</var> element.</p>
- <p>Let <var title="">target document</var> be the <code title="">ownerDocument</code> of <var title="">target</var>.</p>
+ <p>If this raises an exception, then abort these steps.</p>
+
+ <p>Otherwise, let <var title="">new children</var> be <var title="">target</var>s returned.</p>
</li>
<li>
<p>Set the <code title="">ownerDocument</code> of all the nodes in
- <var title="">new children</var> to the <var title="">target
- document</var>.</p>
+ <var title="">new children</var> to <var title="">target</var>'s
+ document.</p>
</li>
@@ -8259,193 +8250,7 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0
</li>
- </ol><!-- XXX must make sure we spec that innerHTML et al causes mutation
- events to fire, but document.write() doesn't. (the latter is already
- req-stated in the parser section, btw) --><!-- http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/innerhtml.asp --><!-- http://lxr.mozilla.org/seamonkey/source/content/html/content/src/nsGenericHTMLElement.cpp#879
- note script execution disabled
- http://lxr.mozilla.org/seamonkey/source/content/base/src/nsContentUtils.cpp#3308
- http://trac.webkit.org/projects/webkit/browser/trunk/WebCore/html/HTMLElement.cpp#L295
- http://trac.webkit.org/projects/webkit/browser/trunk/WebCore/html/HTMLElement.cpp#L242
- http://trac.webkit.org/projects/webkit/browser/trunk/WebCore/html/HTMLTokenizer.cpp#L1742
- --><h4 id=dynamic-markup-insertion-in-xml><span class=secno>3.7.3 </span>Dynamic markup insertion in XML</h4>
-
- <p>In an XML context, the <dfn id=dom-innerhtml-xml title=dom-innerHTML-XML><code>innerHTML</code></dfn> DOM attribute
- on <code><a href=#htmlelement>HTMLElement</a></code>s must return a string in the form of an
- <a href=http://www.w3.org/TR/xml/#wf-entities>internal general
- parsed entity</a>, and on <code><a href=#htmldocument>HTMLDocument</a></code>s must return a
- string in the form of a <a href=http://www.w3.org/TR/xml/#sec-well-formed>document
- entity</a>. The string returned must be XML namespace-well-formed
- and must be an isomorphic serialization of all of that node's child
- nodes, in document order. User agents may adjust prefixes and
- namespace declarations in the serialization (and indeed might be
- forced to do so in some cases to obtain namespace-well-formed
- XML). For the <code title=dom-innerHTML-XML><a href=#dom-innerhtml-xml>innerHTML</a></code>
- attribute on <code><a href=#htmlelement>HTMLElement</a></code> objects, if any of the
- elements in the serialization are in no namespace, the default
- namespace in scope for those elements must be explicitly declared as
- the empty string.<!-- because otherwise round-tripping might break
- since it'll pick up the surrounding default ns when setting -->
- (This doesn't apply to the <code title=dom-innerHTML-XML><a href=#dom-innerhtml-xml>innerHTML</a></code> attribute on
- <code><a href=#htmldocument>HTMLDocument</a></code> objects.) <a href=#refsXML>[XML]</a> <a href=#refsXMLNS>[XMLNS]</a></p>
-
- <p>If any of the following cases are found in the DOM being
- serialized, the user agent must raise an
- <code><a href=#invalid_state_err>INVALID_STATE_ERR</a></code> exception:</p>
-
- <ul><li>A <code>Document</code> node with no child element nodes.</li>
-
- <li>A <code>DocumentType</code> node that has an external subset
- public identifier that contains characters that are not matched by
- the XML <code title="">PubidChar</code> production. <a href=#refsXML>[XML]</a></li>
-
- <li>A <code>DocumentType</code> node that has an external subset
- system identifier that contains both a U+0022 QUOTATION MARK ('"')
- and a U+0027 APOSTROPHE ("'").</li>
-
- <li>A node with a prefix or local name containing a U+003A COLON
- (":").</li>
-
- <li>An <code>Attr</code> node, <code>Text</code> node,
- <code>CDATASection</code> node, <code>Comment</code> node, or
- <code>ProcessingInstruction</code> node whose data contains
- characters that are not matched by the XML <code title="">Char</code> production. <a href=#refsXML>[XML]</a></li>
-
- <li>A <code>CDATASection</code> node whose data contains the string
- "<code title="">]]&gt;</code>".</li>
-
- <li>A <code>Comment</code> node whose data contains two adjacent
- U+002D HYPHEN-MINUS (-) characters or ends with such a
- character.</li>
-
- <li>A <code>ProcessingInstruction</code> node whose target name is
- an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">xml</code>".</li>
-
- <li>A <code>ProcessingInstruction</code> node whose target name
- contains a U+003A COLON (":").</li>
-
- <li>A <code>ProcessingInstruction</code> node whose data contains
- the string "<code title="">?&gt;</code>".</li>
-
- </ul><p class=note>These are the only ways to make a DOM
- unserializable. The DOM enforces all the other XML constraints; for
- example, trying to set an attribute with a name that contains an
- equals sign (=) will raised an <code><a href=#invalid_character_err>INVALID_CHARACTER_ERR</a></code>
- exception.</p>
-
- <p>On setting, in an XML context, the <code title=dom-innerHTML-XML><a href=#dom-innerhtml-xml>innerHTML</a></code> DOM attribute on
- <code><a href=#htmlelement>HTMLElement</a></code>s and <code><a href=#htmldocument>HTMLDocument</a></code>s must run
- the following algorithm:</p>
-
- <ol><li>
-
- <p>The user agent must create a new <span>XML parser</span><!-- XXX xref -->.</p>
-
- </li>
-
- <li>
-
- <p>If the <code title=dom-innerHTML-XML><a href=#dom-innerhtml-xml>innerHTML</a></code>
- attribute is being set on an element, the user agent must
- <span>feed the parser</span> just created the string corresponding
- to the start tag of that element, declaring all the namespace
- prefixes that are in scope on that element in the DOM, as well as
- declaring the default namespace (if any) that is in scope on that
- element in the DOM.</p>
-
- <p>A namespace prefix is in scope if the DOM Core <code title="">lookupNamespaceURI()</code> method on the element would
- return a non-null value for that prefix.</p>
-
- <p>The default namespace is the namespace for which the DOM Core
- <code title="">isDefaultNamespace()</code> method on the element
- would return true.</p>
-
- </li>
-
- <li>
-
- <p>The user agent must <span>feed the parser</span> just created
- the string being assigned into the <code title=dom-innerHTML-XML><a href=#dom-innerhtml-xml>innerHTML</a></code> attribute.</p>
-
- </li>
-
- <li>
-
- <p>If the <code title=dom-innerHTML-XML><a href=#dom-innerhtml-xml>innerHTML</a></code>
- attribute is being set on an element, the user agent must
- <span>feed the parser</span> the string corresponding to the end
- tag of that element.</p>
-
- </li>
-
- <li>
-
- <p>If the parser found an XML well-formedness or XML namespace
- well-formedness error, the attribute's setter must raise a
- <code><a href=#syntax_err>SYNTAX_ERR</a></code> exception and abort these steps.</p>
-
- </li>
-
- <li>
-
- <p>The user agent must remove the children nodes of the node whose
- <code title=dom-innerHTML-XML><a href=#dom-innerhtml-xml>innerHTML</a></code> attribute is
- being set.</p>
-
- </li>
-
- <li>
-
- <p>If the attribute is being set on a <code>Document</code> node,
- let <var title="">new children</var> be the children of the
- document, preserving their order. Otherwise, the attribute is
- being set on an <code>Element</code> node; let <var title="">new
- children</var> be the children of the document's root element,
- preserving their order.</p>
-
- </li>
-
- <li>
-
- <p>If the attribute is being set on a <code>Document</code> node,
- let <var title="">target document</var> be that
- <code>Document</code> node. Otherwise, the attribute is being set
- on an <code>Element</code> node; let <var title="">target
- document</var> be the <code title="">ownerDocument</code> of that
- <code>Element</code>.</p>
-
- </li>
-
- <li>
-
- <p>Set the <code title="">ownerDocument</code> of all the nodes in
- <var title="">new children</var> to the <var title="">target
- document</var>.</p>
-
- </li>
-
- <li>
-
- <p>Append all the <var title="">new children</var> nodes to the
- node whose <code title=dom-innerHTML-XML><a href=#dom-innerhtml-xml>innerHTML</a></code>
- attribute is being set, preserving their order.</p>
-
- </li>
-
- </ol><hr><p>In an XML context, the <dfn id=dom-document-write-xml title=dom-document-write-XML><code>document.write()</code></dfn>
- and <dfn id=dom-insertadjacenthtml-xml title=dom-insertAdjacentHTML-XML><code>insertAdjacentHTML()</code></dfn>
- methods, and the <dfn id=dom-outerhtml-xml title=dom-outerHTML-XML><code>outerHTML</code></dfn> attribute on
- both getting and setting, must raise an
- <code><a href=#invalid_access_err>INVALID_ACCESS_ERR</a></code> exception.</p>
-
-<!--
-Where would document.write() insert?
-Consider: data:text/xml,<script xmlns="http://www.w3.org/1999/xhtml"><![CDATA[ document.write('<foo>Test</foo>'); ]]></script>
--->
-
-
-
-
- <h2 id=semantics><span class=secno>4 </span>The elements of HTML</h2>
+ </ol><h2 id=semantics><span class=secno>4 </span>The elements of HTML</h2>
<h3 id=the-root-element><span class=secno>4.1 </span>The root element</h3>
@@ -9561,7 +9366,7 @@ people expect to have work and what is necessary.
node">text nodes</a> that are direct children of the
<code><a href=#the-style-element>style</a></code> element (not any other nodes such as comments or
elements), in <a href=#tree-order>tree order</a>, to the style system. For
- XML-based styling languages, user agents must pass all the children
+ XML-based styling languages, user agents must pass all the child
nodes of the <code><a href=#the-style-element>style</a></code> element to the style system.</p>
<p>All <a href=#url title=URL>URLs</a> found by the styling language's
@@ -9786,21 +9591,12 @@ people expect to have work and what is necessary.
if set, must be propagated to the clone when it is created. The
second is a flag indicating whether the element was
<dfn id=parser-inserted>"parser-inserted"</dfn>. This flag is set by the <a href=#html-parser>HTML
- parser</a> and is used to handle <code title=dom-document-write-HTML><a href=#dom-document-write-html>document.write()</a></code> calls. The
- third and fourth pieces of metadata are <dfn id="the-script-block's-type"><var>the script block's
+ parser</a> and is used to handle <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code> calls. The third
+ and fourth pieces of metadata are <dfn id="the-script-block's-type"><var>the script block's
type</var></dfn> and <dfn id="the-script-block's-character-encoding"><var>the script block's character
encoding</var></dfn>. They are determined when the script is run,
based on the attributes on the element at that time.</p>
- <p>When an <span>XML parser</span><!-- XXX xref --> creates a
- <code><a href=#script>script</a></code> element, it must be marked as being
- <a href=#parser-inserted>"parser-inserted"</a>. When the element's end tag is
- parsed, the user agent must <a href=#running-a-script title="running a
- script">run</a> the <code><a href=#script>script</a></code> element.</p>
-
- <p class=note>Equivalent requirements exist for the <a href=#html-parser>HTML
- parser</a>, but they are detailed in that section instead.</p>
-
<p>When a <code><a href=#script>script</a></code> element that is marked as neither
having <a href=#already-executed>"already executed"</a> nor being
<a href=#parser-inserted>"parser-inserted"</a> is <a href=#insert-an-element-into-a-document title="insert an element
@@ -9858,15 +9654,10 @@ people expect to have work and what is necessary.
<p>If <a href=#concept-n-noscript title=concept-n-noscript>scripting is
disabled</a> for the <code><a href=#script>script</a></code> element, or if the
- <code><a href=#script>script</a></code> element was created by an <span>XML
- parser</span><!-- XXX xref --> that itself was created as part of
- the processing of the <code title=dom-innerHTML-XML><a href=#dom-innerhtml-xml>innerHTML</a></code> attribute's setter<!--
- no need to worry about the HTML case, as the HTML parser handles
- that for us -->, or if the user agent does not <a href=#support-the-scripting-language>support the
- scripting language</a> given by <var><a href="#the-script-block's-type">the script block's
- type</a></var> for this <code><a href=#script>script</a></code> element, then the user
- agent must abort these steps at this point. The script is not
- executed.</p>
+ user agent does not <a href=#support-the-scripting-language>support the scripting language</a>
+ given by <var><a href="#the-script-block's-type">the script block's type</a></var> for this
+ <code><a href=#script>script</a></code> element, then the user agent must abort these
+ steps at this point. The script is not executed.</p>
</li>
@@ -10194,6 +9985,12 @@ o............A....e
</div>
+ <p class=note>When inserted using the <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code> method,
+ <code><a href=#script>script</a></code> elements execute (typically synchronously), but
+ when inserted using <code title=dom-innerHTML><a href=#dom-innerhtml>innerHTML</a></code> and <code title=dom-outerHTML><a href=#dom-outerhtml>outerHTML</a></code> attributes, they do not
+ execute at all.</p>
+
+
<h5 id=scriptingLanguages><span class=secno>4.3.1.1 </span>Scripting languages</h5>
@@ -10357,7 +10154,7 @@ not-slash = %x0000-002E / %x0030-%10FFFF
<a href=#text-node>text node</a> children of the <code><a href=#the-noscript-element>noscript</a></code>
element.</li>
- <li>Set the <code title=dom-innerHTML-HTML><a href=#dom-innerhtml-html>innerHTML</a></code>
+ <li>Set the <code title=dom-innerHTML><a href=#dom-innerhtml>innerHTML</a></code>
attribute of the <var title="">parent element</var> to the value
of <var title="">s</var>. (This, as a side-effect, causes the
<code><a href=#the-noscript-element>noscript</a></code> element to be removed from the
@@ -44097,7 +43894,7 @@ http://developer.apple.com/documentation/AppleApplications/Conceptual/SafariJSPr
steps:</p>
<ol><li><p>If the document is an <span>XML document</span>, then
throw an <code><a href=#invalid_access_err>INVALID_ACCESS_ERR</a></code> exception and abort
- these steps.</li>
+ these steps.</li><!-- XXX support XML? -->
<li><p>If the <var title="">value</var> argument wasn't
specified, abort these steps without doing anything.</li>
<li><p>If there is a selection, act as if the user had requested
@@ -46343,10 +46140,11 @@ interface <dfn id=messagechannel>MessageChannel</dfn> {
- <h2 id=syntax><span class=secno>8 </span>The HTML syntax</h2>
+ <h2 id=syntax><span class=secno>8 </span><dfn>The HTML syntax</dfn></h2>
<p class=note>This section only describes the rules for <code title="">text/html</code> resources. Rules for XML resources are
- defined by the XML specifications.</p>
+ discussed in the section below entitled "<a href=#the-xhtml-syntax>The XHTML
+ syntax</a>".</p>
<h3 id=writing-html-documents><span class=secno>8.1 </span>Writing HTML documents</h3>
@@ -47094,16 +46892,13 @@ interface <dfn id=messagechannel>MessageChannel</dfn> {
and conformance checkers.</em></p>
<p>The rules for parsing <a href=#xml-documents>XML documents</a> (and thus
- <a href=#xhtml5>XHTML</a> documents) into DOM trees are covered by the XML
- and Namespaces in XML specifications, and are out of scope of this
- specification. <a href=#refsXML>[XML]</a> <a href=#refsXMLNS>[XMLNS]</a> <!-- XXX refs --></p>
+ <a href=#xhtml5>XHTML</a> documents) into DOM trees are covered by the next
+ section, entitled "<a href=#the-xhtml-syntax>The XHTML syntax</a>".</p>
<p>For <a href=#html-documents>HTML documents</a>, user agents must use the parsing
rules described in this section to generate the DOM trees. Together,
these rules define what is referred to as the <dfn id=html-parser>HTML
- parser</dfn>.</p><!-- XXX should probably remove that "must" since
- it'll be redundant with something in the navigating processing model
- eventually -->
+ parser</dfn>.</p>
<div class=note>
@@ -47166,7 +46961,7 @@ interface <dfn id=messagechannel>MessageChannel</dfn> {
<p>In the common case, the data handled by the tokenization stage
comes from the network, but <a href=#dynamic-markup-insertion title="dynamic markup
- insertion">it can also come from script</a>, e.g. using the <code title=dom-document-write-HTML><a href=#dom-document-write-html>document.write()</a></code> API.</p>
+ insertion">it can also come from script</a>, e.g. using the <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code> API.</p>
<p><img alt="" src=images/parsing-model-overview.png></p>
@@ -47723,7 +47518,7 @@ interface <dfn id=messagechannel>MessageChannel</dfn> {
<p>The <dfn id=insertion-point>insertion point</dfn> is the position (just before a
character or just before the end of the input stream) where content
- inserted using <code title=dom-document-write-HTML><a href=#dom-document-write-html>document.write()</a></code> is actually
+ inserted using <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code> is actually
inserted. The insertion point is relative to the position of the
character immediately after it, it is not an absolute offset into
the input stream. Initially, the insertion point is
@@ -49549,7 +49344,7 @@ interface <dfn id=messagechannel>MessageChannel</dfn> {
<p id=mutation-during-parsing>DOM mutation events must not fire
for changes caused by the UA parsing the document. (Conceptually,
the parser is not mutating the DOM, it is constructing it.) This
- includes the parsing of any content inserted using <code title=dom-document-write-HTML><a href=#dom-document-write-html>document.write()</a></code> and <code title=dom-document-writeln><a href=#dom-document-writeln>document.writeln()</a></code> calls. <a href=#refsDOM3EVENTS>[DOM3EVENTS]</a></p>
+ 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=#refsDOM3EVENTS>[DOM3EVENTS]</a></p>
<p class=note>Not all of the tag names mentioned below are
conformant tag names in this specification; many are included to
@@ -50212,11 +50007,12 @@ interface <dfn id=messagechannel>MessageChannel</dfn> {
<p>Mark the element as being <a href=#parser-inserted>"parser-inserted"</a>.</p>
- <p class=note>This ensures that, if the script is external, any
- <code title=dom-document-write-HTML><a href=#dom-document-write-html>document.write()</a></code>
+ <p class=note>This ensures that, if the script is external,
+ any <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code>
calls in the script will execute in-line, instead of blowing the
document away, as would happen in most other cases. It also
- prevents the script from executing until the end tag is seen.</p>
+ prevents the script from executing until the end tag is
+ seen.</p>
</li>
@@ -51657,9 +51453,9 @@ interface <dfn id=messagechannel>MessageChannel</dfn> {
one.</p>
<p><a href=#running-a-script title="running a script">Run</a> the <var title="">script</var>. This might cause some script to execute,
- which might cause <a href=#dom-document-write-html title=dom-document-write-HTML>new
- characters to be inserted into the tokeniser</a>, and might
- cause the tokeniser to output more tokens, resulting in a <a href=#nestedParsing>reentrant invocation of the parser</a>.</p>
+ which might cause <a href=#dom-document-write title=dom-document-write>new characters
+ to be inserted into the tokeniser</a>, and might cause the
+ tokeniser to output more tokens, resulting in a <a href=#nestedParsing>reentrant invocation of the parser</a>.</p>
<p>Decrement the parser's <a href=#script-nesting-level>script nesting level</a> by
one. If the parser's <a href=#script-nesting-level>script nesting level</a> is zero,
@@ -51675,7 +51471,7 @@ interface <dfn id=messagechannel>MessageChannel</dfn> {
<a href=#pending-external-script>pending external script</a>, then:</p>
<dl class=switch><dt>If the tree construction stage is <a href=#nestedParsing>being called reentrantly</a>, say from a
- call to <code title=dom-document-write-HTML><a href=#dom-document-write-html>document.write()</a></code>:</dt>
+ call to <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code>:</dt>
<dd><p>Set the <a href=#parser-pause-flag>parser pause flag</a> to true, and abort
the processing of any nested invocations of the tokeniser,
@@ -53369,16 +53165,16 @@ http://lxr.mozilla.org/seamonkey/search?string=nested
<h3 id=parsing-html-fragments><span class=secno>8.5 </span>Parsing HTML fragments</h3>
<p>The following steps form the <dfn id=html-fragment-parsing-algorithm>HTML fragment parsing
- algorithm</dfn>. The algorithm takes as input a DOM
- <code>Element</code>, referred to as the <var title="">context</var>
- element, which gives the context for the parser, as well as <var title="">input</var>, a string to parse, and returns a list of zero
- or more nodes.</p>
+ algorithm</dfn>. The algorithm optionally takes as input an
+ <code>Element</code> node, referred to as the <var title="">context</var> element, which gives the context for the
+ parser, as well as <var title="">input</var>, a string to parse, and
+ returns a list of zero or more nodes.</p>
<p class=note>Parts marked <dfn id=fragment-case>fragment case</dfn> in algorithms
in the parser section are parts that only occur if the parser was
- created for the purposes of this algorithm. The algorithms have been
- annotated with such markings for informational purposes only; such
- markings have no normative weight. If it is possible for a condition
+ created for the purposes of this algorithm (and with a <var title="">context</var> element). The algorithms have been annotated
+ with such markings for informational purposes only; such markings
+ have no normative weight. If it is possible for a condition
described as a <a href=#fragment-case>fragment case</a> to occur even when the
parser wasn't created for the purposes of handling this algorithm,
then that is an error in the specification.</p>
@@ -53399,85 +53195,92 @@ http://lxr.mozilla.org/seamonkey/search?string=nested
<li>
- <p>Set the <a href=#html-parser>HTML parser</a>'s <a href=#tokenization>tokenization</a>
- stage's <a href=#content-model-flag>content model flag</a> according to the <var title="">context</var> element, as follows:</p>
+ <p>If there is a <var title="">context</var> element, run these
+ substeps:</p>
- <dl class=switch><dt>If it is a <code><a href=#the-title-element>title</a></code> or <code><a href=#the-textarea-element>textarea</a></code>
- element</dt>
+ <ol><li>
- <dd>Set the <a href=#content-model-flag>content model flag</a> to
- the RCDATA state.</dd>
+ <p>Set the <a href=#html-parser>HTML parser</a>'s <a href=#tokenization>tokenization</a>
+ stage's <a href=#content-model-flag>content model flag</a> according to the <var title="">context</var> element, as follows:</p>
+ <dl class=switch><dt>If it is a <code><a href=#the-title-element>title</a></code> or <code><a href=#the-textarea-element>textarea</a></code>
+ element</dt>
- <dt>If it is a <code><a href=#the-style-element>style</a></code>, <code><a href=#script>script</a></code>,
- <code>xmp</code>, <code><a href=#the-iframe-element>iframe</a></code>, <code>noembed</code>, or
- <code>noframes</code> element</dt>
+ <dd>Set the <a href=#content-model-flag>content model flag</a> to
+ the RCDATA state.</dd>
- <dd>Set the <a href=#content-model-flag>content model flag</a> to
- the CDATA state.</dd>
+ <dt>If it is a <code><a href=#the-style-element>style</a></code>, <code><a href=#script>script</a></code>,
+ <code>xmp</code>, <code><a href=#the-iframe-element>iframe</a></code>, <code>noembed</code>, or
+ <code>noframes</code> element</dt>
- <dt>If it is a <code><a href=#the-noscript-element>noscript</a></code> element</dt>
+ <dd>Set the <a href=#content-model-flag>content model flag</a> to
+ the CDATA state.</dd>
- <dd>If the <a href=#scripting-flag>scripting flag</a> is enabled, set the
- <a href=#content-model-flag>content model flag</a> to the CDATA
- state. Otherwise, set the <a href=#content-model-flag>content model flag</a> to the
- PCDATA state.</dd>
+ <dt>If it is a <code><a href=#the-noscript-element>noscript</a></code> element</dt>
- <dt>If it is a <code>plaintext</code> element</dt>
+ <dd>If the <a href=#scripting-flag>scripting flag</a> is enabled, set the
+ <a href=#content-model-flag>content model flag</a> to the CDATA
+ state. Otherwise, set the <a href=#content-model-flag>content model flag</a> to the
+ PCDATA state.</dd>
- <dd>Set the <a href=#content-model-flag>content model flag</a> to
- PLAINTEXT.</dd>
+ <dt>If it is a <code>plaintext</code> element</dt>
- <dt>Otherwise</dt>
+ <dd>Set the <a href=#content-model-flag>content model flag</a> to
+ PLAINTEXT.</dd>
- <dd>Set the <a href=#content-model-flag>content model flag</a> to the PCDATA
- state.</dd>
- </dl></li>
+ <dt>Otherwise</dt>
- <li>
+ <dd>Leave the <a href=#content-model-flag>content model flag</a> in the PCDATA
+ state.</dd>
- <p>Let <var title="">root</var> be a new <code><a href=#the-html-element>html</a></code> element
- with no attributes.</p>
+ </dl></li>
- </li>
+ <li>
- <li>
+ <p>Let <var title="">root</var> be a new <code><a href=#the-html-element>html</a></code> element
+ with no attributes.</p>
- <p>Append the element <var title="">root</var> to the
- <code>Document</code> node created above.</p>
+ </li>
- </li>
+ <li>
- <li>
+ <p>Append the element <var title="">root</var> to the
+ <code>Document</code> node created above.</p>
- <p>Set up the parser's <a href=#stack-of-open-elements>stack of open elements</a> so that
- it contains just the single element <var title="">root</var>.</p>
+ </li>
- </li>
+ <li>
- <li>
+ <p>Set up the parser's <a href=#stack-of-open-elements>stack of open elements</a> so that
+ it contains just the single element <var title="">root</var>.</p>
- <p><a href=#reset-the-insertion-mode-appropriately title="reset the insertion mode appropriately">Reset the
- parser's insertion mode appropriately</a>.</p>
+ </li>
- <p class=note>The parser will reference the <var title="">context</var> element as part of that algorithm.</p>
+ <li>
- </li>
+ <p><a href=#reset-the-insertion-mode-appropriately title="reset the insertion mode appropriately">Reset the
+ parser's insertion mode appropriately</a>.</p>
- <li>
+ <p class=note>The parser will reference the <var title="">context</var> element as part of that algorithm.</p>
- <p>Set the parser's <a href=#form-element-pointer><code>form</code> element pointer</a>
- to the nearest node to the <var title="">context</var> element
- that is a <code><a href=#the-form-element>form</a></code> element (going straight up the
- ancestor chain, and including the element itself, if it is a
- <code><a href=#the-form-element>form</a></code> element), or, if there is no such
- <code><a href=#the-form-element>form</a></code> element, to null.</p>
+ </li>
- </li>
+ <li>
+
+ <p>Set the parser's <a href=#form-element-pointer><code>form</code> element pointer</a>
+ to the nearest node to the <var title="">context</var> element
+ that is a <code><a href=#the-form-element>form</a></code> element (going straight up the
+ ancestor chain, and including the element itself, if it is a
+ <code><a href=#the-form-element>form</a></code> element), or, if there is no such
+ <code><a href=#the-form-element>form</a></code> element, to null.</p>
+
+ </li>
+
+ </ol></li>
<li>
@@ -53497,8 +53300,12 @@ http://lxr.mozilla.org/seamonkey/search?string=nested
<li>
- <p>Return all the child nodes of <var title="">root</var>,
- preserving the document order.</p>
+ <p>If there is a <var title="">context</var> element, return the
+ child nodes of <var title="">root</var>, in <a href=#tree-order>tree
+ order</a>.</p>
+
+ <p>Otherwise, return the children of the <code>Document</code>
+ object, in <a href=#tree-order>tree order</a>.</p>
</li>
@@ -55658,7 +55465,221 @@ http://lxr.mozilla.org/seamonkey/search?string=nested
- <h2 id=rendering><span class=secno>9 </span>Rendering</h2>
+ <h2 id=the-xhtml-syntax><span class=secno>9 </span><dfn>The XHTML syntax</dfn></h2>
+
+ <p class=note>This section only describes the rules for XML
+ resources. Rules for <code title="">text/html</code> resources are
+ discussed in the section above entitled "<a href=#syntax>The HTML
+ syntax</a>".</p>
+
+
+ <h3 id=writing-xhtml-documents><span class=secno>9.1 </span>Writing XHTML documents</h3>
+
+ <p>The syntax for using HTML with XML, whether in XHTML documents or
+ embedded in other XML documents, is defined in the XML and
+ Namespaces in XML specifications. <a href=#refsXML>[XML]</a> <a href=#refsXMLNS>[XMLNS]</a></p>
+
+ <p>This specification does not define any syntax-level requirements
+ beyond those defined for XML proper.</p>
+
+
+ <h3 id=parsing-xhtml-documents><span class=secno>9.2 </span>Parsing XHTML documents</h3>
+
+ <p>This section describes the relationship between XML and the DOM,
+ with a particular emphasis on how this interacts with HTML.</p>
+
+ <p>An <dfn id=xml-parser>XML parser</dfn>, for the purposes of this specification,
+ is a construct that follows the rules given in the XML specification
+ to map a string of bytes or characters into a <code>Document</code>
+ object.</p>
+
+ <p>An <a href=#xml-parser>XML parser</a> is either associated with a
+ <code>Document</code> object when it is created, or creates one
+ implicitly.</p>
+
+ <p>This <code>Document</code> must then be populated with DOM nodes
+ that represent the tree structure of the input passed to the parser,
+ as defined by the XML specification, the Namespaces in XML
+ specification, and the DOM Core specification. DOM mutation events
+ must not fire for the operations that the <a href=#xml-parser>XML parser</a>
+ performs on the <code>Document</code>'s tree, but the user agent
+ must act as if elements and attributes were individually appended
+ and set respectively so as to trigger rules in this specification
+ regarding what happens when an element in inserted into a document
+ or has its attributes set. <a href=#refsXML>[XML]</a> <a href=#refsXMLNS>[XMLNS]</a> <a href=#refsDOMCORE>[DOMCORE]</a>
+ <a href=#refsDOMEVENTS>[DOMEVENTS]</a></p>
+
+ <p>Certain algorithms in this specification <dfn id=feed-the-parser title="feed the
+ parser">spoon-feed the parser</dfn> characters one string at a
+ time. In such cases, the <a href=#xml-parser>XML parser</a> must act as it
+ would have if faced with a single string consisting of the
+ concatenation of all those characters.</p>
+
+ <p>When an <a href=#xml-parser>XML parser</a> creates a <code><a href=#script>script</a></code>
+ element, it must be marked as being <a href=#parser-inserted>"parser-inserted"</a>.
+ If the parser was originally created for the <a href=#xml-fragment-parsing-algorithm>XML fragment
+ parsing algorithm</a>, then the element must be marked as
+ <a href=#already-executed>"already executed"</a> also. When the element's end tag is
+ parsed, the user agent must <a href=#running-a-script title="running a
+ script">run</a> the <code><a href=#script>script</a></code> element. If this causes
+ there to be a <a href=#pending-external-script>pending external script</a>, then the user
+ agent must <a href=#pause>pause</a> until that script has <a href=#completed-loading>completed
+ loading</a>, and then <a href=#executing-a-script-block title="executing a script
+ block">execute it</a>.</p>
+
+ <p class=note>Since the <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code> API is not
+ available for <a href=#xml-documents>XML documents</a>, much of the complexity in
+ the <a href=#html-parser>HTML parser</a> is not needed in the <a href=#xml-parser>XML
+ parser</a>.</p>
+
+ <p>When an <a href=#xml-parser>XML parser</a> reaches the end of its input, it
+ must <a href=#stop-parsing>stop parsing</a>, following the same rules as the
+ <a href=#html-parser>HTML parser</a>.</p>
+
+
+
+ <h3 id=serializing-xhtml-fragments><span class=secno>9.3 </span>Serializing XHTML fragments</h3>
+
+ <p>The <dfn id=xml-fragment-serialization-algorithm>XML fragment serialization algorithm</dfn> for a
+ <code>Document</code> or <code>Element</code> node either returns a
+ fragment of XML that represents that node or raises an
+ exception.</p>
+
+ <p>For <code>Document</code>s, the algorithm must return a string in
+ the form of a <a href=http://www.w3.org/TR/xml/#sec-well-formed>document
+ entity</a>, if none of the error cases below apply.</p>
+
+ <p>For <code>Element</code>s, the algorithm must return a string in
+ the form of an <a href=http://www.w3.org/TR/xml/#wf-entities>internal general parsed
+ entity</a>, if none of the error cases below apply.</p>
+
+ <p>In both cases, the string returned must be XML
+ namespace-well-formed and must be an isomorphic serialization of all
+ of that node's child nodes, in <a href=#tree-order>tree order</a>. User agents
+ may adjust prefixes and namespace declarations in the serialization
+ (and indeed might be forced to do so in some cases to obtain
+ namespace-well-formed XML).</p>
+
+ <p>For <code>Element</code>s, if any of the elements in the
+ serialization are in no namespace, the default namespace in scope
+ for those elements must be explicitly declared as the empty
+ string.<!-- because otherwise round-tripping might break since it'll
+ pick up the surrounding default ns when setting --> (This doesn't
+ apply in the <code>Document</code> case.) <a href=#refsXML>[XML]</a> <a href=#refsXMLNS>[XMLNS]</a></p>
+
+ <p>If any of the following error cases are found in the DOM subtree
+ being serialized, then the algorithm raises an
+ <code><a href=#invalid_state_err>INVALID_STATE_ERR</a></code> exception instead of returning a
+ string:</p>
+
+ <ul><li>A <code>Document</code> node with no child element nodes.</li>
+
+ <li>A <code>DocumentType</code> node that has an external subset
+ public identifier that contains characters that are not matched by
+ the XML <code title="">PubidChar</code> production. <a href=#refsXML>[XML]</a></li>
+
+ <li>A <code>DocumentType</code> node that has an external subset
+ system identifier that contains both a U+0022 QUOTATION MARK ('"')
+ and a U+0027 APOSTROPHE ("'").</li>
+
+ <li>A node with a prefix or local name containing a U+003A COLON
+ (":").</li>
+
+ <li>An <code>Attr</code> node, <code>Text</code> node,
+ <code>CDATASection</code> node, <code>Comment</code> node, or
+ <code>ProcessingInstruction</code> node whose data contains
+ characters that are not matched by the XML <code title="">Char</code> production. <a href=#refsXML>[XML]</a></li>
+
+ <li>A <code>CDATASection</code> node whose data contains the string
+ "<code title="">]]&gt;</code>".</li>
+
+ <li>A <code>Comment</code> node whose data contains two adjacent
+ U+002D HYPHEN-MINUS (-) characters or ends with such a
+ character.</li>
+
+ <li>A <code>ProcessingInstruction</code> node whose target name is
+ an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code title="">xml</code>".</li>
+
+ <li>A <code>ProcessingInstruction</code> node whose target name
+ contains a U+003A COLON (":").</li>
+
+ <li>A <code>ProcessingInstruction</code> node whose data contains
+ the string "<code title="">?&gt;</code>".</li>
+
+ </ul><p class=note>These are the only ways to make a DOM
+ unserializable. The DOM enforces all the other XML constraints; for
+ example, trying to set an attribute with a name that contains an
+ equals sign (=) will raised an <code><a href=#invalid_character_err>INVALID_CHARACTER_ERR</a></code>
+ exception.</p>
+
+
+
+ <h3 id=parsing-xhtml-fragments><span class=secno>9.4 </span>Parsing XHTML fragments</h3>
+
+ <p>The <dfn id=xml-fragment-parsing-algorithm>XML fragment parsing algorithm</dfn> for either returns
+ a <code>Document</code> or raises a <code><a href=#syntax_err>SYNTAX_ERR</a></code>
+ exception. Given a string <var title="">input</var> and an optional
+ context element <var title="">context</var>, the algorithm is as
+ follows:</p>
+
+ <ol><li>
+
+ <p>Create a new <a href=#xml-parser>XML parser</a>.</p>
+
+ </li>
+
+ <li>
+
+ <p>If there is a <var title="">context</var> element, <a href=#feed-the-parser>feed
+ the parser</a> just created the string corresponding to the
+ start tag of that element, declaring all the namespace prefixes
+ that are in scope on that element in the DOM, as well as declaring
+ the default namespace (if any) that is in scope on that element in
+ the DOM.</p>
+
+ <p>A namespace prefix is in scope if the DOM Core <code title="">lookupNamespaceURI()</code> method on the element would
+ return a non-null value for that prefix.</p>
+
+ <p>The default namespace is the namespace for which the DOM Core
+ <code title="">isDefaultNamespace()</code> method on the element
+ would return true.</p>
+
+ </li>
+
+ <li>
+
+ <p><a href=#feed-the-parser>Feed the parser</a> just created the string <var title="">input</var>.</p>
+
+ </li>
+
+ <li>
+
+ <p>If there is a <var title="">context</var> element, <a href=#feed-the-parser>feed
+ the parser</a> just created the string corresponding to the
+ end tag of that element.</p>
+
+ </li>
+
+ <li>
+
+ <p>If there is an XML well-formedness or XML namespace
+ well-formedness error, then raise a <code><a href=#syntax_err>SYNTAX_ERR</a></code>
+ exception and abort these steps.</p>
+
+ </li>
+
+ <li>
+
+ <p>If there is a <var title="">context</var> element, then return
+ the child nodes of the root element of the resulting
+ <code>Document</code>, in <a href=#tree-order>tree order</a>.</p>
+
+ <p>Otherwise, return the children of the <code>Document</code>
+ object, in <a href=#tree-order>tree order</a>.</p>
+
+ </li>
+
+ </ol><h2 id=rendering><span class=secno>10 </span>Rendering</h2>
<!-- XXX
@@ -55839,9 +55860,9 @@ xh|section xh|section xh|section xh|section xh|section xh|h1 { /* same styles as
- <h3 id=rendering-and-menus/toolbars><span class=secno>9.1 </span>Rendering and menus/toolbars</h3>
+ <h3 id=rendering-and-menus/toolbars><span class=secno>10.1 </span>Rendering and menus/toolbars</h3>
- <h4 id="the-'icon'-property"><span class=secno>9.1.1 </span>The 'icon' property</h4>
+ <h4 id="the-'icon'-property"><span class=secno>10.1.1 </span>The 'icon' property</h4>
<p>UAs should use the command's Icon as the default generic icon
provided by the user agent when the 'icon' property computes to
@@ -55852,15 +55873,15 @@ xh|section xh|section xh|section xh|section xh|section xh|h1 { /* same styles as
- <h2 id=obsolete-features><span class=secno>10 </span>Obsolete features</h2>
+ <h2 id=obsolete-features><span class=secno>11 </span>Obsolete features</h2>
<p>Authors and documents must not use the features listed in this
section. They are documented to enable user agents to support legacy
content in an interoperable fashion.</p>
- <h3 id=obsolete-elements><span class=secno>10.1 </span>Obsolete elements</h3>
+ <h3 id=obsolete-elements><span class=secno>11.1 </span>Obsolete elements</h3>
- <h4 id=the-body-element-0><span class=secno>10.1.1 </span>The <code><a href=#the-body-element>body</a></code> element</h4>
+ <h4 id=the-body-element-0><span class=secno>11.1.1 </span>The <code><a href=#the-body-element>body</a></code> element</h4>
<pre class=idl>[XXX] interface <a href=#htmldocument>HTMLDocument</a> {
attribute DOMString <a href=#dom-document-fgcolor title=dom-document-fgColor>fgColor</a>;
@@ -55936,7 +55957,7 @@ xh|section xh|section xh|section xh|section xh|section xh|h1 { /* same styles as
- <h4 id=the-applet-element><span class=secno>10.1.2 </span>The <dfn><code>applet</code></dfn> element</h4>
+ <h4 id=the-applet-element><span class=secno>11.1.2 </span>The <dfn><code>applet</code></dfn> element</h4>
<p>The <code><a href=#the-applet-element>applet</a></code> element is a Java-specific variant of the
<code><a href=#the-embed-element>embed</a></code> element. In HTML5 the <code><a href=#the-applet-element>applet</a></code> element
@@ -55963,7 +55984,7 @@ xh|section xh|section xh|section xh|section xh|section xh|h1 { /* same styles as
- <h3 id=conformance-checkers-0><span class=secno>10.2 </span>Conformance checkers</h3>
+ <h3 id=conformance-checkers-0><span class=secno>11.2 </span>Conformance checkers</h3>
<p>To ease the transition from HTML4 Transitional documents to the
language defined in <em>this</em> specification, conformance
@@ -56037,7 +56058,7 @@ xh|section xh|section xh|section xh|section xh|section xh|h1 { /* same styles as
<li><p>The presence of a <code>noframes</code> element.</li>
- </ul><h2 id=no><span class=secno>11 </span>Things that you can't do with this specification because
+ </ul><h2 id=no><span class=secno>12 </span>Things that you can't do with this specification because
they are better handled using other technologies that are further
described herein</h2>
@@ -56049,7 +56070,7 @@ xh|section xh|section xh|section xh|section xh|section xh|h1 { /* same styles as
that can be integrated into this one. This section covers some of
the more common requests.</p>
- <h3 id=localization><span class=secno>11.1 </span>Localization</h3>
+ <h3 id=localization><span class=secno>12.1 </span>Localization</h3>
<p>If you wish to create localized versions of an HTML application,
the best solution is to preprocess the files on the server, and then
@@ -56058,13 +56079,13 @@ xh|section xh|section xh|section xh|section xh|section xh|h1 { /* same styles as
<!-- <p>XXX example here</p> -->
<!--XXXSVG (remove next section)-->
- <h3 id=declarative-2d-vector-graphics-and-animation><span class=secno>11.2 </span>Declarative 2D vector graphics and animation</h3>
+ <h3 id=declarative-2d-vector-graphics-and-animation><span class=secno>12.2 </span>Declarative 2D vector graphics and animation</h3>
<p>Embedding vector graphics into XHTML documents is the domain of
SVG.</p>
<!-- <p>XXX example here</p> -->
- <h3 id=declarative-3d-scenes><span class=secno>11.3 </span>Declarative 3D scenes</h3>
+ <h3 id=declarative-3d-scenes><span class=secno>12.3 </span>Declarative 3D scenes</h3>
<p>Embedding 3D imagery into XHTML documents is the domain of X3D,
or technologies based on X3D that are namespace-aware.</p>
@@ -56073,7 +56094,7 @@ xh|section xh|section xh|section xh|section xh|section xh|h1 { /* same styles as
- <h3 id=timers><span class=secno>11.4 </span>Timers</h3>
+ <h3 id=timers><span class=secno>12.4 </span>Timers</h3>
<p class=XXX>This section is expected to be moved to its own
specification in due course. It needs a lot of work to actually make
@@ -56153,7 +56174,7 @@ interface <dfn id=timeouthandler>TimeoutHandler</dfn> {
- <h3 id=rendering-and-the-dom><span class=secno>11.5 </span>Rendering and the DOM</h3>
+ <h3 id=rendering-and-the-dom><span class=secno>12.5 </span>Rendering and the DOM</h3>
<p class=XXX>This section is expected to be moved to its own
specification in due course. It needs a lot of work to actually make
View
983 source
@@ -6180,14 +6180,6 @@ interface <dfn>HTMLDocument</dfn> {
<code>Document</code> object.</p> <!-- XXX define
document.onreadystatechange -->
- <p>When a <code>Document</code> is created by an <span>XML
- parser</span>, the <span>current document readiness</span> must be
- changed to "complete" when the parser reaches the end of its input
- stream.</p> <!-- XXX this should be in its own section, and we
- should define 'delay the load event' for XML parsing so that we can
- have the "interactive" state here too. also, XML parser will need to
- fire the /pending state object/, and the 'load' event, and... -->
-
<p>The <dfn
title="dom-document-readyState"><code>readyState</code></dfn> DOM
attribute must, on getting, return the <span>current document
@@ -7853,72 +7845,19 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0
</dl>
+
<h3><dfn>Dynamic markup insertion</dfn></h3>
- <p>APIs for dynamically inserting markup into the document interact
- with the parser, and thus their behavior varies depending on whether
- they are used with <span>HTML documents</span> (and the <span>HTML
- parser</span>) or XHTML in <span>XML documents</span> (and the
- <span>XML parser</span><!-- XXX xref -->). The following table
- cross-references the various versions of these APIs.</p>
+ <p class="note">APIs for dynamically inserting markup into the
+ document interact with the parser, and thus their behavior, varies
+ depending on whether they are used with <span>HTML documents</span>
+ (and the <span>HTML parser</span>) or XHTML in <span>XML
+ documents</span> (and the <span>XML parser</span>).</p>
- <table>
- <thead>
- <tr>
- <td></td>
- <th>For documents that are <span>HTML documents</span></th>
- <th>For documents that are <span>XML documents</span></th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <th><code>document.open()</code></th>
- <td colspan=2><span title="dom-document-open"><code>document.open()</code></span></td>
- </tr>
- <tr>
- <th><dfn title="dom-document-write"><code>document.write()</code></dfn></th>
- <td><span title="dom-document-write-HTML"><code>document.write()</code> in HTML</span></td>
- <td><span title="dom-document-write-XML">not supported</span></td>
- </tr>
- <tr>
- <th><dfn title="dom-innerHTML"><code>innerHTML</code></dfn></th>
- <td><span title="dom-innerHTML-HTML"><code>innerHTML</code> in HTML</span></td>
- <td><span title="dom-innerHTML-XML"><code>innerHTML</code> in XML</span></td>
- </tr>
- <tr>
- <th><dfn title="dom-outerHTML"><code>outerHTML</code></dfn></th>
- <td><span title="dom-outerHTML-HTML"><code>outerHTML</code> in HTML</span></td>
- <td><span title="dom-outerHTML-XML">not supported</span></td>
- </tr>
- <tr>
- <th><dfn title="dom-insertAdjacentHTML"><code>insertAdjacentHTML()</code></dfn></th>
- <td><span title="dom-insertAdjacentHTML-HTML"><code>insertAdjacentHTML()</code> in HTML</span></td>
- <td><span title="dom-insertAdjacentHTML-XML">not supported</span></td>
- </tr>
- </tbody>
- </table>
+ <!-- XXX must make sure we spec that innerHTML et al causes mutation
+ events to fire, but document.write() doesn't. (the latter is already
+ req-stated in the parser section, btw) -->
- <p>Regardless of the parsing mode, the <dfn
- title="dom-document-writeln"><code>document.writeln(...)</code></dfn>
- method must call the <code
- title="dom-document-write">document.write()</code> method with the
- same argument(s), plus an extra argument consisting of a string
- containing a single line feed character (U+000A).</p>
-
- <p class="note">The <code title="dom-innerHTML">innerHTML</code>
- attribute applies to both <code>Element</code> nodes as well as
- <code>Document</code> nodes. The <code
- title="dom-outerHTML">outerHTML</code> and <code
- title="dom-insertAdjacentHTML">insertAdjacentHTML()</code> members,
- on the other hand, only apply to <code>Element</code> nodes.</p>
-
- <p class="note">When inserted using the <code
- title="dom-document-write">document.write()</code> method,
- <code>script</code> elements execute (typically synchronously), but
- when inserted using <code
- title="dom-innerHTML-HTML">innerHTML</code> and <code
- title="dom-outerHTML-HTML">outerHTML</code> attributes, they do not
- execute at all.</p>
<h4>Controlling the input stream</h4>
@@ -8098,16 +8037,31 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0
<span>input stream</span>.</p>
- <h4>Dynamic markup insertion in HTML</h4>
- <p>In HTML, the <dfn
- title="dom-document-write-HTML"><code>document.write(...)</code></dfn>
+
+ <h4><code title="dom-document-write">document.write()</code></h4>
+
+ <p>The <dfn
+ title="dom-document-write"><code>document.write(...)</code></dfn>
method must act as follows:</p>
<ol>
<li>
+ <p>If the method was invoked on an <span title="XML documents">XML
+ document</span>, throw an <code>INVALID_ACCESS_ERR</code>
+ exception and abort these steps.</p>
+
+ <!--
+ Where would document.write() insert?
+ Consider: data:text/xml,<script xmlns="http://www.w3.org/1999/xhtml"><![CDATA[ document.write('<foo>Test</foo>'); ]]></script>
+ -->
+
+ </li>
+
+ <li>
+
<p>If the <span>insertion point</span> is undefined, the <code
title="dom-document-open">open()</code> method must be called
(with no arguments) on the <code title="Document">document</code>
@@ -8145,7 +8099,7 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0
end tag token is emitted by the tokeniser).
<p class="note">If the <code
- title="dom-document-write-HTML">document.write()</code> method was
+ title="dom-document-write">document.write()</code> method was
called from script executing inline (i.e. executing because the
parser parsed a set of <code>script</code> tags), then this is a
<a href="#nestedParsing">reentrant invocation of the
@@ -8161,108 +8115,88 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0
</ol>
- <hr>
-
- <p>On getting, the <dfn
- title="dom-innerHTML-HTML"><code>innerHTML</code></dfn> DOM
- attribute must return the result of running the <span>HTML fragment
- serialization algorithm</span> on the node.</p>
-
- <p>On setting, <strong>if the node is a document</strong>, the <code
- title="dom-innerHTML-HTML">innerHTML</code> DOM attribute must run
- the following algorithm:</p>
- <ol>
+ <h4><code title="dom-document-writeln">document.writeln()</code></h4>
- <li>
+ <p>The <dfn
+ title="dom-document-writeln"><code>document.writeln(...)</code></dfn>
+ method, when invoked, must act as if the <code
+ title="dom-document-write">document.write()</code> method had been
+ invoked with the same argument(s), plus an extra argument consisting
+ of a string containing a single line feed character (U+000A).</p>
- <p>If the document has an <span>active parser</span><!--XXX
- xref-->, then stop that parser, and throw away any pending content
- in the input stream. <span class="XXX">what about if it
- doesn't, because it's either like a text/plain, or Atom, or PDF,
- or XHTML, or image document, or something?</span></p><!-- XXX see
- also document.open() -->
- </li>
- <li>
- <p>Remove the children nodes of the <code>Document</code> whose
- <code title="dom-innerHTML-HTML">innerHTML</code> attribute is
- being set.</p>
+ <h4><code title="dom-innerHTML">innerHTML</code></h4>
- </li>
+ <p>The <dfn title="dom-innerHTML"><code>innerHTML</code></dfn> DOM
+ attribute represents the markup of the node's contents.</p>
- <li>
+ <p>On getting, if the node's document is an <span title="HTML
+ documents">HTML document</span>, then the attribute must return the
+ result of running the <span>HTML fragment serialization
+ algorithm</span> on the node; otherwise, the node's document is an
+ <span title="XML documents">XML document</span>, and the attribute
+ must return the result of running the <span>XML fragment
+ serialization algorithm</span> on the node instead (this might raise
+ an exception instead of returning a string).</p>
- <p>Create a new <span>HTML parser</span>, in its initial state,
- and associate it with the <code>Document</code> node.</p>
+ <p>On setting, the following steps must be run:</p>
- </li>
+ <ol>
-<!-- redundant, the document is forcibly already so labeled if we get here
<li>
- <p>Mark the <code>Document</code> object as being an <span
- title="HTML documents">HTML document</span>.</p>
+ <p>If the node's document is an <span title="HTML documents">HTML
+ document</span>: Invoke the <span>HTML fragment parsing
+ algorithm</span>.</p>
- </li>
--->
-
- <li>
+ <p>If the node's document is an <span title="XML documents">XML
+ document</span>: Invoke the <span>XML fragment parsing
+ algorithm</span>.</p>
- <p>Place into the <span>input stream</span> for the <span>HTML
- parser</span> just created the string being assigned into the
- <code title="dom-innerHTML-HTML">innerHTML</code> attribute.</p>
-
- </li>
+ <p>In either case, the algorithm must be invoked with the string
+ being assigned into the <code
+ title="dom-innerHTML">innerHTML</code> attribute as the <var
+ title="">input</var>. If the node is an <code>Element</code>
+ node, then, in addition, that element must be passed as the <var
+ title="">context</var> element.</p>
- <li>
+ <p>If this raises an exception, then abort these steps.</p>
- <p>Start the parser and let it run until it has consumed all the
- characters just inserted into the input stream. (The
- <code>Document</code> node will have been populated with elements
- and a <code title="event-load">load</code> event will have fired
- on its <span>browsing context</span>'s <code>Window</code>
- object.)</p>
+ <p>Otherwise, let <var title="">new children</var> be the nodes
+ returned.</p>
</li>
- </ol>
-
- <p>Otherwise, if the node is an element, then setting the <code
- title="dom-innerHTML-HTML">innerHTML</code> DOM attribute must cause
- the following algorithm to run instead:</p>
-
- <ol>
-
<li>
- <p>Invoke the <span>HTML fragment parsing algorithm</span>, with
- the element whose <code
- title="dom-innerHTML-HTML">innerHTML</code> attribute is being set
- as the <var title="">context</var> element, and the string being
- assigned into the <code
- title="dom-innerHTML-HTML">innerHTML</code> attribute as the <var
- title="">input</var>. Let <var title="">new children</var> be the
- result of this algorithm.</p>
+ <p>If the attribute is being set on a <code>Document</code> node,
+ and that document has an active <span>HTML parser</span> or
+ <span>XML parser</span>, then stop that parser.</p>
+
+ <p class="XXX">what about if it doesn't, because it's either
+ like a text/plain, or Atom, or PDF, or XHTML, or image document,
+ or something?</p><!-- XXX see also document.open() -->
</li>
<li>
- <p>Remove the children of the element whose <code
- title="dom-innerHTML-HTML">innerHTML</code> attribute is being
- set, without firing any mutation events.</p>
+ <p>Remove the child nodes of the node whose <code
+ title="dom-innerHTML">innerHTML</code> attribute is being set.</p>
</li>
<li>
- <p>Let <var title="">target document</var> be the <code
- title="">ownerDocument</code> of the <code>Element</code> node
- whose <code title="dom-innerHTML-HTML">innerHTML</code> attribute
- is being set.</p>
+ <p>If the attribute is being set on a <code>Document</code>
+ node, let <var title="">target document</var> be that
+ <code>Document</code> node. Otherwise, the attribute is being
+ set on an <code>Element</code> node; let <var title="">target
+ document</var> be the <code title="">ownerDocument</code> of
+ that <code>Element</code>.</p>
</li>
@@ -8277,31 +8211,39 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0
<li>
<p>Append all the <var title="">new children</var> nodes to the
- node whose <code title="dom-innerHTML-HTML">innerHTML</code>
- attribute is being set, preserving their order, without firing any
- mutation events.</p>
+ node whose <code title="dom-innerHTML">innerHTML</code> attribute
+ is being set, preserving their order, without firing any mutation
+ events.</p>
</li>
</ol>
- <hr>
- <p>On getting, the <dfn
- title="dom-outerHTML-HTML"><code>outerHTML</code></dfn> DOM
- attribute must return the result of running the <span>HTML fragment
- serialization algorithm</span> on a fictional node whose only child
- is the node on which the attribute was invoked.</p>
- <p>On setting, the <code title="dom-outerHTML-HTML">outerHTML</code>
- DOM attribute must cause the following algorithm to run:</p>
+ <h4><code title="dom-outerHTML">outerHTML</code></h4>
+
+ <p>The <dfn title="dom-outerHTML"><code>outerHTML</code></dfn> DOM
+ attribute represents the markup of the element and its contents.</p>
+
+ <p>On getting, if the node's document is an <span title="HTML
+ documents">HTML document</span>, then the attribute must return the
+ result of running the <span>HTML fragment serialization
+ algorithm</span> on a fictional node whose only child is the node on
+ which the attribute was invoked; otherwise, the node's document is
+ an <span title="XML documents">XML document</span>, and the
+ attribute must return the result of running the <span>XML fragment
+ serialization algorithm</span> on that fictional node instead (this
+ might raise an exception instead of returning a string).</p>
+
+ <p>On setting, the following steps must be run:</p>
<ol>
<li>
<p>Let <var title="">target</var> be the element whose <code
- title="dom-innerHTML-HTML">outerHTML</code> attribute is being
+ title="dom-outerHTML">outerHTML</code> attribute is being
set.</p>
</li>
@@ -8334,27 +8276,32 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0
<li>
- <p>Invoke the <span>HTML fragment parsing algorithm</span>, with
- <var title="">parent</var> as the <var title="">context</var>
- element and the string being assigned into the <code
- title="dom-outerHTML-HTML">outerHTML</code> attribute as the <var
- title="">input</var>. Let <var title="">new children</var> be the
- result of this algorithm.</p>
+ <p>If <var title="">target</var>'s document is an <span
+ title="HTML documents">HTML document</span>: Invoke the <span>HTML
+ fragment parsing algorithm</span>.</p>
- </li>
+ <p>If <var title="">target</var>'s document is an <span title="XML
+ documents">XML document</span>: Invoke the <span>XML fragment
+ parsing algorithm</span>.</p>
- <li>
+ <p>In either case, the algorithm must be invoked with the string
+ being assigned into the <code
+ title="dom-outerHTML">outerHTML</code> attribute as the <var
+ title="">input</var>, and <var title="">parent</var> as the <var
+ title="">context</var> element.</p>
+
+ <p>If this raises an exception, then abort these steps.</p>
- <p>Let <var title="">target document</var> be the <code
- title="">ownerDocument</code> of <var title="">target</var>.</p>
+ <p>Otherwise, let <var title="">new children</var> be <var
+ title="">target</var>s returned.</p>
</li>
<li>
<p>Set the <code title="">ownerDocument</code> of all the nodes in
- <var title="">new children</var> to the <var title="">target
- document</var>.</p>
+ <var title="">new children</var> to <var title="">target</var>'s
+ document.</p>
</li>
@@ -8369,12 +8316,14 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0
</ol>
- <hr>
+
+
+ <h4><code title="dom-insertAdjacentHTML">insertAdjacentHTML()</code></h4>
<p>The <dfn
- title="dom-insertAdjacentHTML-HTML"><code>insertAdjacentHTML(<var
+ title="dom-insertAdjacentHTML"><code>insertAdjacentHTML(<var
title="">position</var>, <var title="">text</var>)</code></dfn>
- method, when invoked, must run the following steps:</p>
+ method, when invoked, must run the following algorithm:</p>
<ol>
@@ -8444,26 +8393,31 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0
<li>
- <p>Invoke the <span>HTML fragment parsing algorithm</span>, with
- the <var title="">context</var> element being that selected by the
- previous step, and <var title="">input</var> being the method's
- <var title="">text</var> argument. Let <var title="">new
- children</var> be the result of this algorithm.</p>
+ <p>If <var title="">target</var>'s document is an <span
+ title="HTML documents">HTML document</span>: Invoke the <span>HTML
+ fragment parsing algorithm</span>.</p>
- </li>
+ <p>If <var title="">target</var>'s document is an <span title="XML
+ documents">XML document</span>: Invoke the <span>XML fragment
+ parsing algorithm</span>.</p>
- <li>
+ <p>In either case, the algorithm must be invoked with <var
+ title="">text</var> as the <var title="">input</var>, and the
+ element selected in by the previous step as the <var
+ title="">context</var> element.</p>
+
+ <p>If this raises an exception, then abort these steps.</p>
- <p>Let <var title="">target document</var> be the <code
- title="">ownerDocument</code> of <var title="">target</var>.</p>
+ <p>Otherwise, let <var title="">new children</var> be <var
+ title="">target</var>s returned.</p>
</li>
<li>
<p>Set the <code title="">ownerDocument</code> of all the nodes in
- <var title="">new children</var> to the <var title="">target
- document</var>.</p>
+ <var title="">new children</var> to <var title="">target</var>'s
+ document.</p>
</li>
@@ -8527,219 +8481,6 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0
</ol>
- <!-- XXX must make sure we spec that innerHTML et al causes mutation
- events to fire, but document.write() doesn't. (the latter is already
- req-stated in the parser section, btw) -->
-
- <!-- http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/innerhtml.asp -->
- <!-- http://lxr.mozilla.org/seamonkey/source/content/html/content/src/nsGenericHTMLElement.cpp#879
- note script execution disabled
- http://lxr.mozilla.org/seamonkey/source/content/base/src/nsContentUtils.cpp#3308
- http://trac.webkit.org/projects/webkit/browser/trunk/WebCore/html/HTMLElement.cpp#L295
- http://trac.webkit.org/projects/webkit/browser/trunk/WebCore/html/HTMLElement.cpp#L242
- http://trac.webkit.org/projects/webkit/browser/trunk/WebCore/html/HTMLTokenizer.cpp#L1742
- -->
-
-
- <h4>Dynamic markup insertion in XML</h4>
-
- <p>In an XML context, the <dfn
- title="dom-innerHTML-XML"><code>innerHTML</code></dfn> DOM attribute
- on <code>HTMLElement</code>s must return a string in the form of an
- <a href="http://www.w3.org/TR/xml/#wf-entities">internal general
- parsed entity</a>, and on <code>HTMLDocument</code>s must return a
- string in the form of a <a
- href="http://www.w3.org/TR/xml/#sec-well-formed">document
- entity</a>. The string returned must be XML namespace-well-formed
- and must be an isomorphic serialization of all of that node's child
- nodes, in document order. User agents may adjust prefixes and
- namespace declarations in the serialization (and indeed might be
- forced to do so in some cases to obtain namespace-well-formed
- XML). For the <code title="dom-innerHTML-XML">innerHTML</code>
- attribute on <code>HTMLElement</code> objects, if any of the
- elements in the serialization are in no namespace, the default
- namespace in scope for those elements must be explicitly declared as
- the empty string.<!-- because otherwise round-tripping might break
- since it'll pick up the surrounding default ns when setting -->
- (This doesn't apply to the <code
- title="dom-innerHTML-XML">innerHTML</code> attribute on
- <code>HTMLDocument</code> objects.) <a href="#refsXML">[XML]</a> <a
- href="#refsXMLNS">[XMLNS]</a></p>
-
- <p>If any of the following cases are found in the DOM being
- serialized, the user agent must raise an
- <code>INVALID_STATE_ERR</code> exception:</p>
-
- <ul>
-
- <li>A <code>Document</code> node with no child element nodes.</li>
-
- <li>A <code>DocumentType</code> node that has an external subset
- public identifier that contains characters that are not matched by
- the XML <code title="">PubidChar</code> production. <a
- href="#refsXML">[XML]</a></li>
-
- <li>A <code>DocumentType</code> node that has an external subset
- system identifier that contains both a U+0022 QUOTATION MARK ('"')
- and a U+0027 APOSTROPHE ("'").</li>
-
- <li>A node with a prefix or local name containing a U+003A COLON
- (":").</li>
-
- <li>An <code>Attr</code> node, <code>Text</code> node,
- <code>CDATASection</code> node, <code>Comment</code> node, or
- <code>ProcessingInstruction</code> node whose data contains
- characters that are not matched by the XML <code
- title="">Char</code> production. <a href="#refsXML">[XML]</a></li>
-
- <li>A <code>CDATASection</code> node whose data contains the string
- "<code title="">]]&gt;</code>".</li>
-
- <li>A <code>Comment</code> node whose data contains two adjacent
- U+002D HYPHEN-MINUS (-) characters or ends with such a
- character.</li>
-
- <li>A <code>ProcessingInstruction</code> node whose target name is
- an <span>ASCII case-insensitive</span> match for the string "<code
- title="">xml</code>".</li>
-
- <li>A <code>ProcessingInstruction</code> node whose target name
- contains a U+003A COLON (":").</li>
-
- <li>A <code>ProcessingInstruction</code> node whose data contains
- the string "<code title="">?></code>".</li>
-
- </ul>
-
- <p class="note">These are the only ways to make a DOM
- unserializable. The DOM enforces all the other XML constraints; for
- example, trying to set an attribute with a name that contains an
- equals sign (=) will raised an <code>INVALID_CHARACTER_ERR</code>
- exception.</p>
-
- <p>On setting, in an XML context, the <code
- title="dom-innerHTML-XML">innerHTML</code> DOM attribute on
- <code>HTMLElement</code>s and <code>HTMLDocument</code>s must run
- the following algorithm:</p>
-
- <ol>
-
- <li>
-
- <p>The user agent must create a new <span>XML parser</span><!-- XXX xref -->.</p>
-
- </li>
-
- <li>
-
- <p>If the <code title="dom-innerHTML-XML">innerHTML</code>
- attribute is being set on an element, the user agent must
- <span>feed the parser</span> just created the string corresponding
- to the start tag of that element, declaring all the namespace
- prefixes that are in scope on that element in the DOM, as well as
- declaring the default namespace (if any) that is in scope on that
- element in the DOM.</p>
-
- <p>A namespace prefix is in scope if the DOM Core <code
- title="">lookupNamespaceURI()</code> method on the element would
- return a non-null value for that prefix.</p>
-
- <p>The default namespace is the namespace for which the DOM Core
- <code title="">isDefaultNamespace()</code> method on the element
- would return true.</p>
-
- </li>
-
- <li>
-
- <p>The user agent must <span>feed the parser</span> just created
- the string being assigned into the <code
- title="dom-innerHTML-XML">innerHTML</code> attribute.</p>
-
- </li>
-
- <li>
-
- <p>If the <code title="dom-innerHTML-XML">innerHTML</code>
- attribute is being set on an element, the user agent must
- <span>feed the parser</span> the string corresponding to the end
- tag of that element.</p>
-
- </li>
-
- <li>
-
- <p>If the parser found an XML well-formedness or XML namespace
- well-formedness error, the attribute's setter must raise a
- <code>SYNTAX_ERR</code> exception and abort these steps.</p>
-
- </li>
-
- <li>
-
- <p>The user agent must remove the children nodes of the node whose
- <code title="dom-innerHTML-XML">innerHTML</code> attribute is
- being set.</p>
-
- </li>
-
- <li>
-
- <p>If the attribute is being set on a <code>Document</code> node,
- let <var title="">new children</var> be the children of the
- document, preserving their order. Otherwise, the attribute is
- being set on an <code>Element</code> node; let <var title="">new
- children</var> be the children of the document's root element,
- preserving their order.</p>
-
- </li>
-
- <li>
-
- <p>If the attribute is being set on a <code>Document</code> node,
- let <var title="">target document</var> be that
- <code>Document</code> node. Otherwise, the attribute is being set
- on an <code>Element</code> node; let <var title="">target
- document</var> be the <code title="">ownerDocument</code> of that
- <code>Element</code>.</p>
-
- </li>
-
- <li>
-
- <p>Set the <code title="">ownerDocument</code> of all the nodes in
- <var title="">new children</var> to the <var title="">target
- document</var>.</p>
-
- </li>
-
- <li>
-
- <p>Append all the <var title="">new children</var> nodes to the
- node whose <code title="dom-innerHTML-XML">innerHTML</code>
- attribute is being set, preserving their order.</p>
-
- </li>
-
- </ol>
-
- <hr>
-
- <p>In an XML context, the <dfn
- title="dom-document-write-XML"><code>document.write()</code></dfn>
- and <dfn
- title="dom-insertAdjacentHTML-XML"><code>insertAdjacentHTML()</code></dfn>
- methods, and the <dfn
- title="dom-outerHTML-XML"><code>outerHTML</code></dfn> attribute on
- both getting and setting, must raise an
- <code>INVALID_ACCESS_ERR</code> exception.</p>
-
-<!--
-Where would document.write() insert?
-Consider: data:text/xml,<script xmlns="http://www.w3.org/1999/xhtml"><![CDATA[ document.write('<foo>Test</foo>'); ]]></script>
--->
-
-
<h2 id="semantics">The elements of HTML</h2>
@@ -10039,7 +9780,7 @@ people expect to have work and what is necessary.
node">text nodes</span> that are direct children of the
<code>style</code> element (not any other nodes such as comments or
elements), in <span>tree order</span>, to the style system. For
- XML-based styling languages, user agents must pass all the children
+ XML-based styling languages, user agents must pass all the child
nodes of the <code>style</code> element to the style system.</p>
<p>All <span title="URL">URLs</span> found by the styling language's
@@ -10302,21 +10043,12 @@ people expect to have work and what is necessary.
second is a flag indicating whether the element was
<dfn>"parser-inserted"</dfn>. This flag is set by the <span>HTML
parser</span> and is used to handle <code
- title="dom-document-write-HTML">document.write()</code> calls. The
- third and fourth pieces of metadata are <dfn><var>the script block's
+ title="dom-document-write">document.write()</code> calls. The third
+ and fourth pieces of metadata are <dfn><var>the script block's
type</var></dfn> and <dfn><var>the script block's character
encoding</var></dfn>. They are determined when the script is run,
based on the attributes on the element at that time.</p>
- <p>When an <span>XML parser</span><!-- XXX xref --> creates a
- <code>script</code> element, it must be marked as being
- <span>"parser-inserted"</span>. When the element's end tag is
- parsed, the user agent must <span title="running a
- script">run</span> the <code>script</code> element.</p>
-
- <p class="note">Equivalent requirements exist for the <span>HTML
- parser</span>, but they are detailed in that section instead.</p>
-
<p>When a <code>script</code> element that is marked as neither
having <span>"already executed"</span> nor being
<span>"parser-inserted"</span> is <span title="insert an element
@@ -10395,16 +10127,10 @@ people expect to have work and what is necessary.
<p>If <span title="concept-n-noscript">scripting is
disabled</span> for the <code>script</code> element, or if the
- <code>script</code> element was created by an <span>XML
- parser</span><!-- XXX xref --> that itself was created as part of
- the processing of the <code
- title="dom-innerHTML-XML">innerHTML</code> attribute's setter<!--
- no need to worry about the HTML case, as the HTML parser handles
- that for us -->, or if the user agent does not <span>support the
- scripting language</span> given by <var>the script block's
- type</var> for this <code>script</code> element, then the user
- agent must abort these steps at this point. The script is not
- executed.</p>
+ user agent does not <span>support the scripting language</span>
+ given by <var>the script block's type</var> for this
+ <code>script</code> element, then the user agent must abort these
+ steps at this point. The script is not executed.</p>
</li>
@@ -10786,6 +10512,15 @@ o............A....e
</div>
+ <p class="note">When inserted using the <code
+ title="dom-document-write">document.write()</code> method,
+ <code>script</code> elements execute (typically synchronously), but
+ when inserted using <code
+ title="dom-innerHTML">innerHTML</code> and <code
+ title="dom-outerHTML">outerHTML</code> attributes, they do not
+ execute at all.</p>
+
+
<h5 id="scriptingLanguages">Scripting languages</h5>
@@ -10971,7 +10706,7 @@ not-slash = %x0000-002E / %x0030-%10FFFF
<span>text node</span> children of the <code>noscript</code>
element.</li>
- <li>Set the <code title="dom-innerHTML-HTML">innerHTML</code>
+ <li>Set the <code title="dom-innerHTML">innerHTML</code>
attribute of the <var title="">parent element</var> to the value
of <var title="">s</var>. (This, as a side-effect, causes the
<code>noscript</code> element to be removed from the
@@ -50335,7 +50070,7 @@ http://developer.apple.com/documentation/AppleApplications/Conceptual/SafariJSPr
<ol>
<li><p>If the document is an <span>XML document</span>, then
throw an <code>INVALID_ACCESS_ERR</code> exception and abort
- these steps.</p></li>
+ these steps.</p></li><!-- XXX support XML? -->
<li><p>If the <var title="">value</var> argument wasn't
specified, abort these steps without doing anything.</p></li>
<li><p>If there is a selection, act as if the user had requested
@@ -52932,11 +52667,12 @@ interface <dfn>MessageChannel</dfn> {
- <h2 id="syntax">The HTML syntax</h2>
+ <h2 id="syntax"><dfn>The HTML syntax</dfn></h2>
<p class="note">This section only describes the rules for <code
title="">text/html</code> resources. Rules for XML resources are
- defined by the XML specifications.</p>
+ discussed in the section below entitled "<span>The XHTML
+ syntax</span>".</p>
<h3>Writing HTML documents</h3>
@@ -53767,17 +53503,13 @@ interface <dfn>MessageChannel</dfn> {
and conformance checkers.</em></p>
<p>The rules for parsing <span>XML documents</span> (and thus
- <span>XHTML</span> documents) into DOM trees are covered by the XML
- and Namespaces in XML specifications, and are out of scope of this
- specification. <a href="#refsXML">[XML]</a> <a
- href="#refsXMLNS">[XMLNS]</a> <!-- XXX refs --></p>
+ <span>XHTML</span> documents) into DOM trees are covered by the next
+ section, entitled "<span>The XHTML syntax</span>".</p>
<p>For <span>HTML documents</span>, user agents must use the parsing
rules described in this section to generate the DOM trees. Together,
these rules define what is referred to as the <dfn>HTML
- parser</dfn>.</p><!-- XXX should probably remove that "must" since
- it'll be redundant with something in the navigating processing model
- eventually -->
+ parser</dfn>.</p>
<div class="note">
@@ -53841,7 +53573,7 @@ interface <dfn>MessageChannel</dfn> {
<p>In the common case, the data handled by the tokenization stage
comes from the network, but <span title="dynamic markup
insertion">it can also come from script</span>, e.g. using the <code
- title="dom-document-write-HTML">document.write()</code> API.</p>
+ title="dom-document-write">document.write()</code> API.</p>
<p><img src="images/parsing-model-overview.png" alt=""></p>
@@ -54494,7 +54226,7 @@ interface <dfn>MessageChannel</dfn> {
<p>The <dfn>insertion point</dfn> is the position (just before a
character or just before the end of the input stream) where content
inserted using <code
- title="dom-document-write-HTML">document.write()</code> is actually
+ title="dom-document-write">document.write()</code> is actually
inserted. The insertion point is relative to the position of the
character immediately after it, it is not an absolute offset into
the input stream. Initially, the insertion point is
@@ -56576,7 +56308,7 @@ interface <dfn>MessageChannel</dfn> {
for changes caused by the UA parsing the document. (Conceptually,
the parser is not mutating the DOM, it is constructing it.) This
includes the parsing of any content inserted using <code
- title="dom-document-write-HTML">document.write()</code> and <code
+ title="dom-document-write">document.write()</code> and <code
title="dom-document-writeln">document.writeln()</code> calls. <a
href="#refsDOM3EVENTS">[DOM3EVENTS]</a></p>
@@ -57306,11 +57038,12 @@ interface <dfn>MessageChannel</dfn> {
<p>Mark the element as being <span>"parser-inserted"</span>.</p>
- <p class="note">This ensures that, if the script is external, any
- <code title="dom-document-write-HTML">document.write()</code>
+ <p class="note">This ensures that, if the script is external,
+ any <code title="dom-document-write">document.write()</code>
calls in the script will execute in-line, instead of blowing the
document away, as would happen in most other cases. It also
- prevents the script from executing until the end tag is seen.</p>
+ prevents the script from executing until the end tag is
+ seen.</p>
</li>
@@ -58872,9 +58605,9 @@ interface <dfn>MessageChannel</dfn> {
<p><span title="running a script">Run</span> the <var
title="">script</var>. This might cause some script to execute,
- which might cause <span title="dom-document-write-HTML">new
- characters to be inserted into the tokeniser</span>, and might
- cause the tokeniser to output more tokens, resulting in a <a
+ which might cause <span title="dom-document-write">new characters
+ to be inserted into the tokeniser</span>, and might cause the
+ tokeniser to output more tokens, resulting in a <a
href="#nestedParsing">reentrant invocation of the parser</a>.</p>
<p>Decrement the parser's <span>script nesting level</span> by
@@ -58895,7 +58628,7 @@ interface <dfn>MessageChannel</dfn> {
<dt>If the tree construction stage is <a
href="#nestedParsing">being called reentrantly</a>, say from a
call to <code
- title="dom-document-write-HTML">document.write()</code>:</dt>
+ title="dom-document-write">document.write()</code>:</dt>
<dd><p>Set the <span>parser pause flag</span> to true, and abort
the processing of any nested invocations of the tokeniser,
@@ -60757,17 +60490,18 @@ http://lxr.mozilla.org/seamonkey/search?string=nested
<h3>Parsing HTML fragments</h3>
<p>The following steps form the <dfn>HTML fragment parsing
- algorithm</dfn>. The algorithm takes as input a DOM
- <code>Element</code>, referred to as the <var title="">context</var>
- element, which gives the context for the parser, as well as <var
- title="">input</var>, a string to parse, and returns a list of zero
- or more nodes.</p>
+ algorithm</dfn>. The algorithm optionally takes as input an
+ <code>Element</code> node, referred to as the <var
+ title="">context</var> element, which gives the context for the
+ parser, as well as <var title="">input</var>, a string to parse, and
+ returns a list of zero or more nodes.</p>
<p class="note">Parts marked <dfn>fragment case</dfn> in algorithms
in the parser section are parts that only occur if the parser was
- created for the purposes of this algorithm. The algorithms have been
- annotated with such markings for informational purposes only; such
- markings have no normative weight. If it is possible for a condition
+ created for the purposes of this algorithm (and with a <var
+ title="">context</var> element). The algorithms have been annotated
+ with such markings for informational purposes only; such markings
+ have no normative weight. If it is possible for a condition
described as a <span>fragment case</span> to occur even when the
parser wasn't created for the purposes of handling this algorithm,
then that is an error in the specification.</p>
@@ -60790,89 +60524,100 @@ http://lxr.mozilla.org/seamonkey/search?string=nested
<li>
- <p>Set the <span>HTML parser</span>'s <span>tokenization</span>
- stage's <span>content model flag</span> according to the <var
- title="">context</var> element, as follows:</p>
+ <p>If there is a <var title="">context</var> element, run these
+ substeps:</p>
- <dl class="switch">
+ <ol>
- <dt>If it is a <code>title</code> or <code>textarea</code>
- element</dt>
+ <li>
- <dd>Set the <span>content model flag</span> to
- the RCDATA state.</dd>
+ <p>Set the <span>HTML parser</span>'s <span>tokenization</span>
+ stage's <span>content model flag</span> according to the <var
+ title="">context</var> element, as follows:</p>
+ <dl class="switch">
- <dt>If it is a <code>style</code>, <code>script</code>,
- <code>xmp</code>, <code>iframe</code>, <code>noembed</code>, or
- <code>noframes</code> element</dt>
+ <dt>If it is a <code>title</code> or <code>textarea</code>
+ element</dt>
- <dd>Set the <span>content model flag</span> to
- the CDATA state.</dd>
+ <dd>Set the <span>content model flag</span> to
+ the RCDATA state.</dd>
- <dt>If it is a <code>noscript</code> element</dt>
+ <dt>If it is a <code>style</code>, <code>script</code>,
+ <code>xmp</code>, <code>iframe</code>, <code>noembed</code>, or
+ <code>noframes</code> element</dt>
- <dd>If the <span>scripting flag</span> is enabled, set the
- <span>content model flag</span> to the CDATA
- state. Otherwise, set the <span>content model flag</span> to the
- PCDATA state.</dd>
+ <dd>Set the <span>content model flag</span> to
+ the CDATA state.</dd>
- <dt>If it is a <code>plaintext</code> element</dt>
+ <dt>If it is a <code>noscript</code> element</dt>
- <dd>Set the <span>content model flag</span> to
- PLAINTEXT.</dd>
+ <dd>If the <span>scripting flag</span> is enabled, set the
+ <span>content model flag</span> to the CDATA
+ state. Otherwise, set the <span>content model flag</span> to the
+ PCDATA state.</dd>
- <dt>Otherwise</dt>
+ <dt>If it is a <code>plaintext</code> element</dt>
- <dd>Set the <span>content model flag</span> to the PCDATA
- state.</dd>
+ <dd>Set the <span>content model flag</span> to
+ PLAINTEXT.</dd>
- </dl>
- </li>
+ <dt>Otherwise</dt>
- <li>
+ <dd>Leave the <span>content model flag</span> in the PCDATA
+ state.</dd>
- <p>Let <var title="">root</var> be a new <code>html</cod