Skip to content

Commit

Permalink
[giow] (1) Share the ownerDocument of template contents amongst the t…
Browse files Browse the repository at this point in the history
…emplates of a document.

Fixing https://www.w3.org/Bugs/Public/show_bug.cgi?id=23795
Affected topics: DOM APIs, HTML

git-svn-id: http://svn.whatwg.org/webapps@8270 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Nov 12, 2013
1 parent e74da98 commit 5a2bc16
Show file tree
Hide file tree
Showing 3 changed files with 147 additions and 41 deletions.
58 changes: 44 additions & 14 deletions complete.html
Expand Up @@ -3702,7 +3702,7 @@ <h4 id=dependencies><span class=secno>2.2.2 </span>Dependencies</h4>
<li><dfn id=dom-element-id title=dom-Element-id><code>id</code></dfn> attribute</li>
<li><dfn id=textcontent><code>textContent</code></dfn> attribute</li>

<li>The <dfn id=concept-node-insert title=concept-node-insert>insert</dfn>, <dfn id=concept-node-append title=concept-node-append>append</dfn>, <dfn id=concept-node-remove title=concept-node-remove>remove</dfn>, and <dfn id=concept-node-replace title=concept-node-replace>replace</dfn> algorithms for nodes</li>
<li>The <dfn id=concept-node-insert title=concept-node-insert>insert</dfn>, <dfn id=concept-node-append title=concept-node-append>append</dfn>, <dfn id=concept-node-remove title=concept-node-remove>remove</dfn>, <dfn id=concept-node-replace title=concept-node-replace>replace</dfn>, and <dfn id=concept-node-adopt title=concept-node-adopt>adopt</dfn> algorithms for nodes</li>
<li>The <dfn id=nodes-are-inserted>nodes are inserted</dfn> and <dfn id=nodes-are-removed>nodes are removed</dfn> concepts</li>
<li>The <dfn id=attribute-list>attribute list</dfn> concept.</li>
<li>The <dfn id=concept-cd-data title=concept-cd-data>data</dfn> of a text node.</li>
Expand Down Expand Up @@ -52559,27 +52559,57 @@ <h4 id=the-template-element><span class=secno>4.12.3 </span>The <dfn><code>templ
is its <dfn id=template-contents>template contents</dfn>. When a <code><a href=#the-template-element>template</a></code> element is created, the user
agent must run the following steps to establish the <a href=#template-contents>template contents</a>:</p>

<ol><li><p>Let <var title="">doc</var> be the <code><a href=#the-template-element>template</a></code> element's <code title=dom-node-ownerdocument><a href=#dom-node-ownerdocument>ownerDocument</a></code>.</li>
<ol><li><p>Let <var title="">doc</var> be the <code><a href=#the-template-element>template</a></code> element's <code title=dom-Node-ownerDocument><a href=#dom-node-ownerdocument>ownerDocument</a></code>'s <a href=#appropriate-template-contents-owner-document>appropriate template contents owner
document</a>.</li>

<li>
<li><p>Create a <code><a href=#documentfragment>DocumentFragment</a></code> object whose <code title=dom-Node-ownerDocument><a href=#dom-node-ownerdocument>ownerDocument</a></code> is <var title="">doc</var>.</li>

<li><p>Set the <code><a href=#the-template-element>template</a></code> element's <a href=#template-contents>template contents</a> to the newly
created <code><a href=#documentfragment>DocumentFragment</a></code> object.</li>

</ol><p>A <code><a href=#document>Document</a></code> <var title="">doc</var>'s <dfn id=appropriate-template-contents-owner-document>appropriate template contents owner
document</dfn> is the <code><a href=#document>Document</a></code> returned by the following algorithm:</p>

<ol><li>

<p>If <var title="">doc</var> has an associated <a href=#browsing-context>browsing context</a>, run these substeps:</p>

<ol><li><p>Let <var title="">new doc</var> be a new <code><a href=#document>Document</a></code> (that does not have a
<a href=#browsing-context>browsing context</a>).</li>
<ol><li>

<li><p>If <var title="">doc</var> is an <a href=#html-documents title="HTML documents">HTML document</a>, mark
<var title="">new doc</var> as an <a href=#html-documents title="HTML documents">HTML document</a>
also.</li>
<p>If <var title="">doc</var> does not yet have an <dfn id=associated-inert-template-document>associated inert template
document</dfn> then run these substeps:</p>

<li><p>Set <var title="">doc</var> to <var title="">new doc</var>.</li>
<ol><li><p>Let <var title="">new doc</var> be a new <code><a href=#document>Document</a></code> (that does not have a
<a href=#browsing-context>browsing context</a>).</li>

</ol></li>
<li><p>If <var title="">doc</var> is an <a href=#html-documents title="HTML documents">HTML document</a>, mark
<var title="">new doc</var> as an <a href=#html-documents title="HTML documents">HTML document</a>
also.</li>

<li><p>Create a <code><a href=#documentfragment>DocumentFragment</a></code> object whose <code title=dom-node-ownerdocument><a href=#dom-node-ownerdocument>ownerDocument</a></code> is <var title="">doc</var>.</li>
<li><p>Let <var title="">doc</var>'s <a href=#associated-inert-template-document>associated inert template document</a> be <var title="">new doc</var>.</li>

<li><p>Set the <code><a href=#the-template-element>template</a></code> element's <a href=#template-contents>template contents</a> to the newly
created <code><a href=#documentfragment>DocumentFragment</a></code> object.</li>
</ol></li>

<li><p>Set <var title="">doc</var> to <var title="">doc</var>'s <a href=#associated-inert-template-document>associated inert
template document</a>.</li>

</ol><p class=note>Each <code><a href=#document>Document</a></code> associated with a <a href=#browsing-context>browsing context</a> thus
gets a single <code><a href=#document>Document</a></code> to act as its proxy for owning the <a href=#template-contents>template
contents</a> of all its <code><a href=#the-template-element>template</a></code> elements, so that they aren't in a
<a href=#browsing-context>browsing context</a> and thus remain inert (e.g. scripts do not run).</p>

</li>

<li><p>Return <var title="">doc</var>.</li>

</ol><p>When a <code><a href=#the-template-element>template</a></code> element changes <code title=dom-Node-ownerDocument><a href=#dom-node-ownerdocument>ownerDocument</a></code>, the user agent must run the following
steps:</p>

<ol><li><p>Let <var title="">doc</var> be the <code><a href=#the-template-element>template</a></code> element's new <code title=dom-Node-ownerDocument><a href=#dom-node-ownerdocument>ownerDocument</a></code>'s <a href=#appropriate-template-contents-owner-document>appropriate template contents owner
document</a>.</li>

<li><p><a href=#concept-node-adopt title=concept-node-adopt>Adopt</a> the <code><a href=#the-template-element>template</a></code> element's
<a href=#template-contents>template contents</a> (a <code><a href=#documentfragment>DocumentFragment</a></code> object) into <var title="">doc</var>.</li>

</ol><p>The <dfn id=dom-template-content title=dom-template-content><code>content</code></dfn> IDL attribute must return the
<code><a href=#the-template-element>template</a></code> element's <a href=#template-contents>template contents</a>.</p>
Expand All @@ -52591,7 +52621,7 @@ <h4 id=the-template-element><span class=secno>4.12.3 </span>The <dfn><code>templ
<ol><li><p>If the <var title="">clone children flag</var> is not set in the calling <a href=#concept-node-clone title=concept-node-clone>clone</a> algorithm, abort these steps.</li>

<li><p>Let <var title="">copied contents</var> be the result of <a href=#concept-node-clone title=concept-node-clone>cloning</a> all the children of <var title="">node</var>'s
<a href=#template-contents>template contents</a>, with <var title="">ownerDocument</var> set to <var title="">copy</var>'s <a href=#template-contents>template contents</a>'s <code title=dom-node-ownerdocument><a href=#dom-node-ownerdocument>ownerDocument</a></code>, and with the <var title="">clone children
<a href=#template-contents>template contents</a>, with <var title="">ownerDocument</var> set to <var title="">copy</var>'s <a href=#template-contents>template contents</a>'s <code title=dom-Node-ownerDocument><a href=#dom-node-ownerdocument>ownerDocument</a></code>, and with the <var title="">clone children
flag</var> set.</li>

<li><p>Append <var title="">copied contents</var> to <var title="">copy</var>'s <a href=#template-contents>template
Expand Down
58 changes: 44 additions & 14 deletions index
Expand Up @@ -3702,7 +3702,7 @@ a.setAttribute('href', 'http://example.com/'); // change the content attribute d
<li><dfn id=dom-element-id title=dom-Element-id><code>id</code></dfn> attribute</li>
<li><dfn id=textcontent><code>textContent</code></dfn> attribute</li>

<li>The <dfn id=concept-node-insert title=concept-node-insert>insert</dfn>, <dfn id=concept-node-append title=concept-node-append>append</dfn>, <dfn id=concept-node-remove title=concept-node-remove>remove</dfn>, and <dfn id=concept-node-replace title=concept-node-replace>replace</dfn> algorithms for nodes</li>
<li>The <dfn id=concept-node-insert title=concept-node-insert>insert</dfn>, <dfn id=concept-node-append title=concept-node-append>append</dfn>, <dfn id=concept-node-remove title=concept-node-remove>remove</dfn>, <dfn id=concept-node-replace title=concept-node-replace>replace</dfn>, and <dfn id=concept-node-adopt title=concept-node-adopt>adopt</dfn> algorithms for nodes</li>
<li>The <dfn id=nodes-are-inserted>nodes are inserted</dfn> and <dfn id=nodes-are-removed>nodes are removed</dfn> concepts</li>
<li>The <dfn id=attribute-list>attribute list</dfn> concept.</li>
<li>The <dfn id=concept-cd-data title=concept-cd-data>data</dfn> of a text node.</li>
Expand Down Expand Up @@ -52559,27 +52559,57 @@ not-slash = %x0000-002E / %x0030-10FFFF
is its <dfn id=template-contents>template contents</dfn>. When a <code><a href=#the-template-element>template</a></code> element is created, the user
agent must run the following steps to establish the <a href=#template-contents>template contents</a>:</p>

<ol><li><p>Let <var title="">doc</var> be the <code><a href=#the-template-element>template</a></code> element's <code title=dom-node-ownerdocument><a href=#dom-node-ownerdocument>ownerDocument</a></code>.</li>
<ol><li><p>Let <var title="">doc</var> be the <code><a href=#the-template-element>template</a></code> element's <code title=dom-Node-ownerDocument><a href=#dom-node-ownerdocument>ownerDocument</a></code>'s <a href=#appropriate-template-contents-owner-document>appropriate template contents owner
document</a>.</li>

<li>
<li><p>Create a <code><a href=#documentfragment>DocumentFragment</a></code> object whose <code title=dom-Node-ownerDocument><a href=#dom-node-ownerdocument>ownerDocument</a></code> is <var title="">doc</var>.</li>

<li><p>Set the <code><a href=#the-template-element>template</a></code> element's <a href=#template-contents>template contents</a> to the newly
created <code><a href=#documentfragment>DocumentFragment</a></code> object.</li>

</ol><p>A <code><a href=#document>Document</a></code> <var title="">doc</var>'s <dfn id=appropriate-template-contents-owner-document>appropriate template contents owner
document</dfn> is the <code><a href=#document>Document</a></code> returned by the following algorithm:</p>

<ol><li>

<p>If <var title="">doc</var> has an associated <a href=#browsing-context>browsing context</a>, run these substeps:</p>

<ol><li><p>Let <var title="">new doc</var> be a new <code><a href=#document>Document</a></code> (that does not have a
<a href=#browsing-context>browsing context</a>).</li>
<ol><li>

<li><p>If <var title="">doc</var> is an <a href=#html-documents title="HTML documents">HTML document</a>, mark
<var title="">new doc</var> as an <a href=#html-documents title="HTML documents">HTML document</a>
also.</li>
<p>If <var title="">doc</var> does not yet have an <dfn id=associated-inert-template-document>associated inert template
document</dfn> then run these substeps:</p>

<li><p>Set <var title="">doc</var> to <var title="">new doc</var>.</li>
<ol><li><p>Let <var title="">new doc</var> be a new <code><a href=#document>Document</a></code> (that does not have a
<a href=#browsing-context>browsing context</a>).</li>

</ol></li>
<li><p>If <var title="">doc</var> is an <a href=#html-documents title="HTML documents">HTML document</a>, mark
<var title="">new doc</var> as an <a href=#html-documents title="HTML documents">HTML document</a>
also.</li>

<li><p>Create a <code><a href=#documentfragment>DocumentFragment</a></code> object whose <code title=dom-node-ownerdocument><a href=#dom-node-ownerdocument>ownerDocument</a></code> is <var title="">doc</var>.</li>
<li><p>Let <var title="">doc</var>'s <a href=#associated-inert-template-document>associated inert template document</a> be <var title="">new doc</var>.</li>

<li><p>Set the <code><a href=#the-template-element>template</a></code> element's <a href=#template-contents>template contents</a> to the newly
created <code><a href=#documentfragment>DocumentFragment</a></code> object.</li>
</ol></li>

<li><p>Set <var title="">doc</var> to <var title="">doc</var>'s <a href=#associated-inert-template-document>associated inert
template document</a>.</li>

</ol><p class=note>Each <code><a href=#document>Document</a></code> associated with a <a href=#browsing-context>browsing context</a> thus
gets a single <code><a href=#document>Document</a></code> to act as its proxy for owning the <a href=#template-contents>template
contents</a> of all its <code><a href=#the-template-element>template</a></code> elements, so that they aren't in a
<a href=#browsing-context>browsing context</a> and thus remain inert (e.g. scripts do not run).</p>

</li>

<li><p>Return <var title="">doc</var>.</li>

</ol><p>When a <code><a href=#the-template-element>template</a></code> element changes <code title=dom-Node-ownerDocument><a href=#dom-node-ownerdocument>ownerDocument</a></code>, the user agent must run the following
steps:</p>

<ol><li><p>Let <var title="">doc</var> be the <code><a href=#the-template-element>template</a></code> element's new <code title=dom-Node-ownerDocument><a href=#dom-node-ownerdocument>ownerDocument</a></code>'s <a href=#appropriate-template-contents-owner-document>appropriate template contents owner
document</a>.</li>

<li><p><a href=#concept-node-adopt title=concept-node-adopt>Adopt</a> the <code><a href=#the-template-element>template</a></code> element's
<a href=#template-contents>template contents</a> (a <code><a href=#documentfragment>DocumentFragment</a></code> object) into <var title="">doc</var>.</li>

</ol><p>The <dfn id=dom-template-content title=dom-template-content><code>content</code></dfn> IDL attribute must return the
<code><a href=#the-template-element>template</a></code> element's <a href=#template-contents>template contents</a>.</p>
Expand All @@ -52591,7 +52621,7 @@ not-slash = %x0000-002E / %x0030-10FFFF
<ol><li><p>If the <var title="">clone children flag</var> is not set in the calling <a href=#concept-node-clone title=concept-node-clone>clone</a> algorithm, abort these steps.</li>

<li><p>Let <var title="">copied contents</var> be the result of <a href=#concept-node-clone title=concept-node-clone>cloning</a> all the children of <var title="">node</var>'s
<a href=#template-contents>template contents</a>, with <var title="">ownerDocument</var> set to <var title="">copy</var>'s <a href=#template-contents>template contents</a>'s <code title=dom-node-ownerdocument><a href=#dom-node-ownerdocument>ownerDocument</a></code>, and with the <var title="">clone children
<a href=#template-contents>template contents</a>, with <var title="">ownerDocument</var> set to <var title="">copy</var>'s <a href=#template-contents>template contents</a>'s <code title=dom-Node-ownerDocument><a href=#dom-node-ownerdocument>ownerDocument</a></code>, and with the <var title="">clone children
flag</var> set.</li>

<li><p>Append <var title="">copied contents</var> to <var title="">copy</var>'s <a href=#template-contents>template
Expand Down

0 comments on commit 5a2bc16

Please sign in to comment.