Skip to content

Commit 0138fb0

Browse files
Special case innerHTML for template parsing; note for outerHTML (#12)
* Special case innerHTML for template parsing; note for outerHTML * template content -> template contents * Adjust note on insertAdjacentHTML with cscott's suggestion
1 parent ff7b32d commit 0138fb0

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

index.html

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,14 @@ <h2>Extensibility</h2>
258258
the new value as <var>markup</var>, and the <a>context object</a> as the
259259
<var>context element</var>.
260260

261+
<li>If the <a>context object</a> is a <code><a>template</a></code> element, then let
262+
<a>context object</a> be the <code><a>template</a></code>'s <a>template contents</a> (a
263+
<code><a>DocumentFragment</a></code>).
264+
265+
<p class=note>Setting <a for="Element">innerHTML</a> on a <a>template</a> element will replace
266+
all the nodes in its <a>template contents</a>
267+
(<a>template</a>.<a data-lt="template contents">content</a>) rather than its <a>children</a>.</p>
268+
261269
<li><a>Replace all</a> with <var>fragment</var> within the <a>context object</a>.
262270
</ol>
263271

@@ -416,6 +424,16 @@ <h2>Extensibility</h2>
416424
the <a>context object</a>'s <a>next sibling</a>.
417425
</dl>
418426
</ol>
427+
428+
<p class=note>No special handling for <code><a>template</a></code> elements is included in the
429+
above "<code>afterbegin</code>" and "<code>beforeend</code>" cases. As with other direct
430+
<a>Node</a>-manipulation APIs (and unlike <a for="Element">innerHTML</a>),
431+
<a for="Element">insertAdjacentHTML</a> does not include any special handling for
432+
<code><a>template</a></code> elements. In most cases you will wish to use
433+
<a>template</a>.<a data-lt="template contents">content</a>.<a for="Element">insertAdjacentHTML</a>
434+
instead of directly manipulating the <a>child nodes</a> of a <code><a>template</a></code>
435+
element.</p>
436+
419437
</section><!-- end Extensions to the Element interface -->
420438

421439
<section><h2>Extensions to the <code><a>Range</a></code> interface</h2>
@@ -586,8 +604,8 @@ <h2>Extensibility</h2>
586604

587605
<p>Otherwise, the algorithm for producing an <a>XML serialization</a> is designed to produce a
588606
serialization that is compatible with the <a>HTML parser</a>. For example, elements in the
589-
<a>HTML namespace</a> that contain no child nodes are serialized with an explicit begin and end
590-
tag rather than using the <a>empty-element tag</a> syntax.
607+
<a>HTML namespace</a> that contain no <a>child nodes</a> are serialized with an explicit begin and
608+
end tag rather than using the <a>empty-element tag</a> syntax.
591609

592610
<p class=note>Per [[DOM4]], <code><a>Attr</a></code> objects do not inherit from <a>Node</a>, and
593611
thus cannot be serialized by the <a>XML serialization algorithm</a>. An attempt to serialize an
@@ -898,7 +916,7 @@ <h2>Extensibility</h2>
898916
(a <code><a>DocumentFragment</a></code>), providing the value of <var>inherited ns</var> for
899917
the <a>context namespace</a>, <var>map</var> for the <a>namespace prefix map</a>,
900918
<var>prefix index</var> for the <a>generated namespace prefix index</a>, and the value of the
901-
<var>require well-formed</var> flag. <span class="note">This allows <a>template content</a> to
919+
<var>require well-formed</var> flag. <span class="note">This allows <a>template contents</a> to
902920
round-trip , given the rules for <a>parsing XHTML documents</a>.</span>
903921

904922
<li>Otherwise, append to <var>markup</var> the result of running the
@@ -1408,7 +1426,7 @@ <h2>Dependencies</h2>
14081426
<dfn><a href="https://www.w3.org/TR/html5/single-page.html#script">script</a></dfn> and
14091427
<dfn><a href="https://www.w3.org/TR/html5/single-page.html#the-template-element">template</a></dfn>
14101428
<li><dfn><a href="https://www.w3.org/TR/html5/single-page.html#void-elements">void elements</a></dfn>
1411-
<li>The <a>template</a>'s <dfn data-lt="template content"><a href="https://www.w3.org/TR/html5/single-page.html#template-contents">template contents</a></dfn>
1429+
<li>The <a>template</a>'s <dfn><a href="https://www.w3.org/TR/html5/single-page.html#template-contents">template contents</a></dfn>
14121430
</ul>
14131431

14141432
The DOM specification [[!DOM4]] defines the following terms used in this document:
@@ -1417,7 +1435,7 @@ <h2>Dependencies</h2>
14171435
<li>The following concepts:
14181436
<dfn><a href="https://www.w3.org/TR/dom/#case-sensitive">case-sensitive</a></dfn> and
14191437
<dfn><a href="https://www.w3.org/TR/dom/#ascii-case-insensitive">ASCII case-insensitive</a></dfn> string comparisons;
1420-
a node's <dfn data-lt="children|child"><a href="https://www.w3.org/TR/dom/#concept-tree-child">children</a></dfn>,
1438+
a node's <dfn data-lt="child|child nodes"><a href="https://www.w3.org/TR/dom/#concept-tree-child">children</a></dfn>,
14211439
<dfn><a href="https://www.w3.org/TR/dom/#concept-tree-first-child">first child</a></dfn>,
14221440
<dfn><a href="https://www.w3.org/TR/dom/#concept-tree-next-sibling">next sibling</a></dfn> and
14231441
<dfn><a href="https://www.w3.org/TR/dom/#concept-tree-parent">parent</a></dfn>;
@@ -1516,6 +1534,7 @@ <h2>Acknowledgements</h2>
15161534
specification is based.
15171535

15181536
<p>Thanks to
1537+
C. Scott Ananian,
15191538
Victor Costan,
15201539
Aryeh Gregor,
15211540
Anne van Kesteren,

0 commit comments

Comments
 (0)