Skip to content

Commit

Permalink
[e] (0) Prepare the ground for insertAdjacentHTML().
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.whatwg.org/webapps@2039 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Aug 11, 2008
1 parent 6b129c6 commit f333cdd
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 69 deletions.
83 changes: 48 additions & 35 deletions index
Expand Up @@ -28,7 +28,7 @@

<h1 id=html-5>HTML 5</h1>

<h2 class="no-num no-toc" id=draft>Draft Recommendation &mdash; 10 August
<h2 class="no-num no-toc" id=draft>Draft Recommendation &mdash; 11 August
2008</h2>

<p>You can take part in this work. <a
Expand Down Expand Up @@ -7634,6 +7634,7 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20html%3E..
// <a href="#dynamic3">dynamic markup insertion</a>
attribute DOMString <a href="#innerhtml" title=dom-innerHTML>innerHTML</a>;
attribute DOMString <a href="#outerhtml" title=dom-outerHTML>outerHTML</a>;
void <a href="#insertadjacenthtml" title=dom-insertAdjacentHTML>insertAdjacentHTML</a>(in DOMString position, in DOMString data);

// <span>metadata attributes</span>
attribute DOMString <a href="#id0" title=dom-id>id</a>;
Expand Down Expand Up @@ -8700,18 +8701,12 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0
<h3 id=dynamic0><span class=secno>3.7 </span><dfn id=dynamic3>Dynamic
markup insertion</dfn></h3>

<p>The <code title=dom-document-write><a
href="#document.write">document.write()</a></code> family of methods and
the <code title=dom-innerHTML><a
href="#innerhtml">innerHTML</a></code>/<code title=dom-outerHTML><a
href="#outerhtml">outerHTML</a></code> family of DOM attributes enable
script authors to dynamically insert markup into the document.

<p>Because these APIs interact with the parser, their behavior varies
depending on whether they are used with <a href="#html-">HTML
documents</a> (and the <a href="#html-0">HTML parser</a>) or XHTML in <a
href="#xml-documents">XML documents</a> (and the <span>XML parser</span>).
The following table cross-references the various versions of these APIs.
<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-">HTML documents</a> (and the <a
href="#html-0">HTML parser</a>) or XHTML in <a href="#xml-documents">XML
documents</a> (and the <span>XML parser</span>). The following table
cross-references the various versions of these APIs.

<table>
<thead>
Expand Down Expand Up @@ -8755,6 +8750,17 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0
title=dom-outerHTML-HTML><code>outerHTML</code> in HTML</a>

<td><a href="#outerhtml1" title=dom-outerHTML-XML>not supported</a>

<tr>
<th><dfn id=insertadjacenthtml
title=dom-insertAdjacentHTML><code>insertAdjacentHTML()</code></dfn>

<td><a href="#insertadjacenthtml0"
title=dom-insertAdjacentHTML-HTML><code>insertAdjacentHTML()</code> in
HTML</a>

<td><a href="#insertadjacenthtml1" title=dom-insertAdjacentHTML-XML>not
supported</a>
</table>

<p>Regardless of the parsing mode, the <dfn id=document.writeln...
Expand All @@ -8767,8 +8773,10 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0
<p class=note>The <code title=dom-innerHTML><a
href="#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="#outerhtml">outerHTML</a></code>
attribute, on the other hand, only applies to <code>Element</code> nodes.
<code title=dom-outerHTML><a href="#outerhtml">outerHTML</a></code> and
<code title=dom-insertAdjacentHTML><a
href="#insertadjacenthtml">insertAdjacentHTML</a></code> attributes, on
the other hand, only apply to <code>Element</code> nodes.

<p class=note>When inserted using the <code title=dom-document-write><a
href="#document.write">document.write()</a></code> method, <code><a
Expand Down Expand Up @@ -9112,7 +9120,12 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0
its place all the <var title="">new children</var> nodes, preserving
their order.</p>
</ol>
<!-- XXX must make sure we spec that innerHTML causes mutation

<hr>

<p class=big-issue><dfn id=insertadjacenthtml0
title=dom-insertAdjacentHTML-HTML><code>insertAdjacentHTML()</code></dfn></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) -->
<!-- http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/innerhtml.asp -->
Expand Down Expand Up @@ -9257,8 +9270,10 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0
<hr>

<p>In an XML context, the <dfn id=document.write0
title=dom-document-write-XML><code>document.write()</code></dfn> method,
and the <dfn id=outerhtml1
title=dom-document-write-XML><code>document.write()</code></dfn> and <dfn
id=insertadjacenthtml1
title=dom-insertAdjacentHTML-XML><code>insertAdjacentHTML()</code></dfn>
methods, and the <dfn id=outerhtml1
title=dom-outerHTML-XML><code>outerHTML</code></dfn> attribute on both
getting and setting, must raise an <code>INVALID_ACCESS_ERR</code>
exception.</p>
Expand Down Expand Up @@ -26202,8 +26217,8 @@ function AddCloud(data, x, y) { ... }</pre>
parser</span> that itself was created as part of the processing of the
<code title=dom-innerHTML-XML><a href="#innerhtml1">innerHTML</a></code>
attribute's setter<!--
no need to worry about the innerHTML-HTML case, as the HTML parser
handles that for us, and outerHTML-XML doesn't work-->,
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">support the scripting
language</a> given by <var><a href="#the-scripts">the script's
type</a></var> for this <code><a href="#script1">script</a></code>
Expand Down Expand Up @@ -45941,9 +45956,10 @@ interface <dfn id=messagechannel>MessageChannel</dfn> {
something other than a <link> or a <style> element; you'd expect
that to break out of the <noscript> but it doesn't. This is an edge
case that doesn't affect the spec, since the algorithm for fragment
parsing is only used for innerHTML/outerHTML, where we know
scripting is enabled. (XXX except maybe if innerHTML is set from
another browsing context on a document with designMode set?) -->
parsing is only used for innerHTML/outerHTML/insertAdjacentHTML(),
where we know scripting is enabled. (XXX except maybe if innerHTML
is set from another browsing context on a document with designMode
set?) -->

<li>If <var title="">node</var> is a <code><a
href="#body0">body</a></code> element, then switch the <span>insertion
Expand Down Expand Up @@ -48125,11 +48141,8 @@ interface <dfn id=messagechannel>MessageChannel</dfn> {
content inserted using <code title=dom-document-write-HTML><a
href="#document.write...">document.write()</a></code> and <code
title=dom-document-writeln><a
href="#document.writeln...">document.writeln()</a></code> calls.<!--
XXX xref -->
<a href="#refsDOM3EVENTS">[DOM3EVENTS]</a></p>
<!-- XXX
what about innerHTML? -->
href="#document.writeln...">document.writeln()</a></code> calls. <a
href="#refsDOM3EVENTS">[DOM3EVENTS]</a>

<p class=note>Not all of the tag names mentioned below are conformant tag
names in this specification; many are included to handle legacy content.
Expand Down Expand Up @@ -49093,10 +49106,12 @@ interface <dfn id=messagechannel>MessageChannel</dfn> {
element as "already executed" prevents it from executing when it is
inserted into the document a few paragraphs below. Thus, scripts missing
their end tags and scripts that were inserted using <code
title=dom-innerHTML-HTML><a
href="#innerhtml0">innerHTML</a></code>/<code
title=dom-outerHTML-HTML><a href="#outerhtml0">outerHTML</a></code>
aren't executed.</p>
title=dom-innerHTML-HTML><a href="#innerhtml0">innerHTML</a></code>,
<code title=dom-outerHTML-HTML><a
href="#outerhtml0">outerHTML</a></code>, or <code
title=dom-insertAdjacentHTML-HTML><a
href="#insertadjacenthtml0">insertAdjacentHTML()</a></code> aren't
executed.</p>

<p>Let the <var title="">old insertion point</var> have the same value as
the current <a href="#insertion">insertion point</a>. Let the <a
Expand Down Expand Up @@ -51494,9 +51509,7 @@ interface <dfn id=messagechannel>MessageChannel</dfn> {
href="#html-fragment0">HTML fragment parsing algorithm</a>, this is a <a
href="#parse2">parse error</a>; ignore the token. (<a
href="#fragment">fragment case</a>)</p>
<!-- can only happen for <html>'s own innerHTML or its children's
outerHTML -->


<p>Otherwise, switch the <span>insertion mode</span> to "<a
href="#after12" title="insertion mode: after after body">after after
body</a>".</p>
Expand Down
75 changes: 41 additions & 34 deletions source
Expand Up @@ -5547,6 +5547,7 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20html%3E..
// <span>dynamic markup insertion</span>
attribute DOMString <span title="dom-innerHTML">innerHTML</span>;
attribute DOMString <span title="dom-outerHTML">outerHTML</span>;
void <span title="dom-insertAdjacentHTML">insertAdjacentHTML</span>(in DOMString position, in DOMString data);

// <span>metadata attributes</span>
attribute DOMString <span title="dom-id">id</span>;
Expand Down Expand Up @@ -6610,19 +6611,12 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0

<h3><dfn>Dynamic markup insertion</dfn></h3>

<p>The <code title="dom-document-write">document.write()</code>
family of methods and the <code
title="dom-innerHTML">innerHTML</code>/<code
title="dom-outerHTML">outerHTML</code> family of DOM attributes
enable script authors to dynamically insert markup into the
document.</p>

<p>Because these APIs interact with the parser, 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>). The
following table cross-references the various versions of these
APIs.</p>
<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>). The following table cross-references the
various versions of these APIs.</p>

<table>
<thead>
Expand Down Expand Up @@ -6652,6 +6646,11 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0
<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>

Expand All @@ -6665,8 +6664,9 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0
<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> attribute, on the other hand,
only applies to <code>Element</code> nodes.</p>
title="dom-outerHTML">outerHTML</code> and <code
title="dom-insertAdjacentHTML">insertAdjacentHTML</code> attributes,
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,
Expand Down Expand Up @@ -7080,7 +7080,12 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0

</ol>

<!-- XXX must make sure we spec that innerHTML causes mutation
<hr>

<p class="big-issue"><dfn title="dom-insertAdjacentHTML-HTML"><code>insertAdjacentHTML()</code></dfn></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) -->

Expand Down Expand Up @@ -7268,7 +7273,9 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0

<p>In an XML context, the <dfn
title="dom-document-write-XML"><code>document.write()</code></dfn>
method, and the <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>
Expand Down Expand Up @@ -23536,13 +23543,13 @@ function AddCloud(data, x, y) { ... }</pre>
by an <span>XML parser</span> 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 innerHTML-HTML case, as the HTML parser
handles that for us, and outerHTML-XML doesn't work-->, or if the
user agent does not <span>support the scripting language</span>
given by <var>the script's type</var> for this <code>script</code>
element, or if the <code>script</code> element has its
<span>"already executed"</span> flag set, then the user agent must
abort these steps at this point. The script is not executed.</p>
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's type</var>
for this <code>script</code> element, or if the
<code>script</code> element has its <span>"already
executed"</span> flag set, then the user agent must abort these
steps at this point. The script is not executed.</p>

</li>

Expand Down Expand Up @@ -43322,9 +43329,10 @@ interface <dfn>MessageChannel</dfn> {
something other than a <link> or a <style> element; you'd expect
that to break out of the <noscript> but it doesn't. This is an edge
case that doesn't affect the spec, since the algorithm for fragment
parsing is only used for innerHTML/outerHTML, where we know
scripting is enabled. (XXX except maybe if innerHTML is set from
another browsing context on a document with designMode set?) -->
parsing is only used for innerHTML/outerHTML/insertAdjacentHTML(),
where we know scripting is enabled. (XXX except maybe if innerHTML
is set from another browsing context on a document with designMode
set?) -->

<li>If <var title="">node</var> is a <code>body</code> element,
then switch the <span>insertion mode</span> to "<span
Expand Down Expand Up @@ -45174,9 +45182,8 @@ interface <dfn>MessageChannel</dfn> {
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-writeln">document.writeln()</code> calls.<!--
XXX xref --> <a href="#refsDOM3EVENTS">[DOM3EVENTS]</a></p><!-- XXX
what about innerHTML? -->
title="dom-document-writeln">document.writeln()</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
Expand Down Expand Up @@ -45913,8 +45920,10 @@ interface <dfn>MessageChannel</dfn> {
"already executed" prevents it from executing when it is inserted
into the document a few paragraphs below. Thus, scripts missing
their end tags and scripts that were inserted using <code
title="dom-innerHTML-HTML">innerHTML</code>/<code
title="dom-outerHTML-HTML">outerHTML</code> aren't executed.</p>
title="dom-innerHTML-HTML">innerHTML</code>, <code
title="dom-outerHTML-HTML">outerHTML</code>, or <code
title="dom-insertAdjacentHTML-HTML">insertAdjacentHTML()</code>
aren't executed.</p>

<p>Let the <var title="">old insertion point</var> have the
same value as the current <span>insertion point</span>. Let
Expand Down Expand Up @@ -48439,8 +48448,6 @@ interface <dfn>MessageChannel</dfn> {
<p>If the parser was originally created as part of the <span>HTML
fragment parsing algorithm</span>, this is a <span>parse
error</span>; ignore the token. (<span>fragment case</span>)</p>
<!-- can only happen for <html>'s own innerHTML or its children's
outerHTML -->

<p>Otherwise, switch the <span>insertion mode</span> to "<span
title="insertion mode: after after body">after after
Expand Down

0 comments on commit f333cdd

Please sign in to comment.