Browse files

[] (0) Define insertAdjacentHTML().

git-svn-id: http://svn.whatwg.org/webapps@2040 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information...
1 parent f333cdd commit 8b28fd39ff4369b23f8cb2cc438d330f603520a9 @Hixie Hixie committed Aug 11, 2008
Showing with 255 additions and 5 deletions.
  1. +103 −3 index
  2. +152 −2 source
View
106 index
@@ -7634,7 +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);
+ void <a href="#insertadjacenthtml" title=dom-insertAdjacentHTML>insertAdjacentHTML</a>(in DOMString position, in DOMString text);
// <span>metadata attributes</span>
attribute DOMString <a href="#id0" title=dom-id>id</a>;
@@ -9123,8 +9123,108 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0
<hr>
- <p class=big-issue><dfn id=insertadjacenthtml0
- title=dom-insertAdjacentHTML-HTML><code>insertAdjacentHTML()</code></dfn></p>
+ <p>The <dfn id=insertadjacenthtml0
+ title=dom-insertAdjacentHTML-HTML><code>insertAdjacentHTML(<var
+ title="">position</var>, <var title="">text</var>)</code></dfn> method,
+ when invoked, must run the following steps:
+
+ <ol>
+ <li>
+ <p>Let <var title="">position</var> and <var title="">text</var> be the
+ method's first and second arguments, respectively.</p>
+
+ <li>
+ <p>Let <var title="">target</var> be the element on which the method was
+ invoked.</p>
+
+ <li>
+ <p>Use the first matching item from this list:</p>
+
+ <dl>
+ <dt>If <var title="">position</var> is an <a href="#ascii">ASCII
+ case-insensitive</a> match for the string "beforebegin"
+
+ <dt>If <var title="">position</var> is an <a href="#ascii">ASCII
+ case-insensitive</a> match for the string "afterend"
+
+ <dd>
+ <p>If <var title="">target</var> has no parent node, then abort these
+ steps.</p>
+
+ <p>If <var title="">target</var>'s parent node is a
+ <code>Document</code> object, then throw a
+ <code>NO_MODIFICATION_ALLOWED_ERR</code> exception and abort these
+ steps.
+
+ <p>Otherwise, let <var title="">context</var> be the parent node of
+ <var title="">target</var>.</p>
+
+ <dt>If <var title="">position</var> is an <a href="#ascii">ASCII
+ case-insensitive</a> match for the string "afterbegin"
+
+ <dt>If <var title="">position</var> is an <a href="#ascii">ASCII
+ case-insensitive</a> match for the string "beforeend"
+
+ <dd>
+ <p>Let <var title="">context</var> be the same as <var
+ title="">target</var>.</p>
+
+ <dt>Otherwise
+
+ <dd>
+ <p>Throw a <code>SYNTAX_ERR</code> exception.</p>
+ </dl>
+
+ <li>
+ <p>Invoke the <a href="#html-fragment0">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>
+
+ <li>
+ <p>Let <var title="">target document</var> be the <code
+ title="">ownerDocument</code> of <var title="">target</var>.</p>
+
+ <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>
+ <p>Use the first matching item from this list:</p>
+
+ <dl>
+ <dt>If <var title="">position</var> is an <a href="#ascii">ASCII
+ case-insensitive</a> match for the string "beforebegin"
+
+ <dd>
+ <p>Insert all the <var title="">new children</var> nodes immediately
+ before <var title="">target</var>, preserving their order.</p>
+
+ <dt>If <var title="">position</var> is an <a href="#ascii">ASCII
+ case-insensitive</a> match for the string "afterbegin"
+
+ <dd>
+ <p>Insert all the <var title="">new children</var> nodes before the
+ first child of <var title="">target</var>, if there is one, preserving
+ their order. If there is no such child, append them all to <var
+ title="">target</var>, preserving their order.</p>
+
+ <dt>If <var title="">position</var> is an <a href="#ascii">ASCII
+ case-insensitive</a> match for the string "beforeend"
+
+ <dd>
+ <p>Append all the <var title="">new children</var> nodes to <var
+ title="">target</var>, preserving their order.</p>
+
+ <dt>If <var title="">position</var> is an <a href="#ascii">ASCII
+ case-insensitive</a> match for the string "afterend"
+
+ <dd>
+ <p>Insert all the <var title="">new children</var> nodes immediately
+ after <var title="">target</var>, preserving their order.</p>
+ </dl>
+ </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) -->
View
154 source
@@ -5547,7 +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);
+ void <span title="dom-insertAdjacentHTML">insertAdjacentHTML</span>(in DOMString position, in DOMString text);
// <span>metadata attributes</span>
attribute DOMString <span title="dom-id">id</span>;
@@ -7082,7 +7082,157 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0
<hr>
- <p class="big-issue"><dfn title="dom-insertAdjacentHTML-HTML"><code>insertAdjacentHTML()</code></dfn></p>
+ <p>The <dfn
+ 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>
+
+ <li>
+
+ <p>Let <var title="">position</var> and <var title="">text</var>
+ be the method's first and second arguments, respectively.</p>
+
+ </li>
+
+ <li>
+
+ <p>Let <var title="">target</var> be the element on which the
+ method was invoked.</p>
+
+ </li>
+
+ <li>
+
+ <p>Use the first matching item from this list:</p>
+
+ <dl>
+
+ <dt>If <var title="">position</var> is an <span>ASCII
+ case-insensitive</span> match for the string "beforebegin"</dt>
+ <dt>If <var title="">position</var> is an <span>ASCII
+ case-insensitive</span> match for the string "afterend"</dt>
+
+ <dd>
+
+ <p>If <var title="">target</var> has no parent node, then abort
+ these steps.</p>
+
+ <p>If <var title="">target</var>'s parent node is a
+ <code>Document</code> object, then throw a
+ <code>NO_MODIFICATION_ALLOWED_ERR</code> exception and abort
+ these steps.
+
+ <p>Otherwise, let <var title="">context</var> be the parent node
+ of <var title="">target</var>.</p>
+
+ </dd>
+
+ <dt>If <var title="">position</var> is an <span>ASCII
+ case-insensitive</span> match for the string "afterbegin"</dt>
+ <dt>If <var title="">position</var> is an <span>ASCII
+ case-insensitive</span> match for the string "beforeend"</dt>
+
+ <dd>
+
+ <p>Let <var title="">context</var> be the same as <var
+ title="">target</var>.</p>
+
+ </dd>
+
+ <dt>Otherwise</dt>
+
+ <dd>
+
+ <p>Throw a <code>SYNTAX_ERR</code> exception.</p>
+
+ </dd>
+
+ </dl>
+
+ </li>
+
+ <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>
+
+ </li>
+
+ <li>
+
+ <p>Let <var title="">target document</var> be the <code
+ title="">ownerDocument</code> of <var title="">target</var>.</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>Use the first matching item from this list:</p>
+
+ <dl>
+
+ <dt>If <var title="">position</var> is an <span>ASCII
+ case-insensitive</span> match for the string "beforebegin"</dt>
+
+ <dd>
+
+ <p>Insert all the <var title="">new children</var> nodes
+ immediately before <var title="">target</var>, preserving their
+ order.</p>
+
+ </dd>
+
+ <dt>If <var title="">position</var> is an <span>ASCII
+ case-insensitive</span> match for the string "afterbegin"</dt>
+
+ <dd>
+
+ <p>Insert all the <var title="">new children</var> nodes before
+ the first child of <var title="">target</var>, if there is one,
+ preserving their order. If there is no such child, append them
+ all to <var title="">target</var>, preserving their order.</p>
+
+ </dd>
+
+ <dt>If <var title="">position</var> is an <span>ASCII
+ case-insensitive</span> match for the string "beforeend"</dt>
+
+ <dd>
+
+ <p>Append all the <var title="">new children</var> nodes to <var
+ title="">target</var>, preserving their order.</p>
+
+ </dd>
+
+ <dt>If <var title="">position</var> is an <span>ASCII
+ case-insensitive</span> match for the string "afterend"</dt>
+
+ <dd>
+
+ <p>Insert all the <var title="">new children</var> nodes
+ immediately after <var title="">target</var>, preserving their
+ order.</p>
+
+ </dd>
+
+ </dl>
+
+ </li>
+
+ </ol>
<!-- XXX must make sure we spec that innerHTML et al causes mutation

0 comments on commit 8b28fd3

Please sign in to comment.