From 8fdf36849fd89d088f9c238be60e6126d983a1f7 Mon Sep 17 00:00:00 2001 From: Travis Leithead Date: Fri, 3 Jun 2016 11:59:54 -0700 Subject: [PATCH 1/3] Special case innerHTML for template parsing; note for outerHTML --- index.html | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 3e346ab..83d0aa2 100644 --- a/index.html +++ b/index.html @@ -258,6 +258,14 @@

Extensibility

the new value as markup, and the context object as the context element. +
  • If the context object is a template element, then let + context object be the template's template content (a + DocumentFragment). + +

    Setting innerHTML on a template element will replace + all the nodes in its template content + (template.content) rather than its children.

    +
  • Replace all with fragment within the context object. @@ -416,6 +424,13 @@

    Extensibility

    the context object's next sibling. + +

    No special handling for template elements is included in the + above "afterbegin" and "beforeend" cases. Unlike + innerHTML, insertAdjacentHTML will insert the given + fragment into a template's children rather than into its + template content.

    +

    Extensions to the Range interface

    @@ -894,7 +909,7 @@

    Extensibility

  • If ns is the HTML namespace, and the node's localName matches the string "template", then this is a template element. Append to markup the result of running the - XML serialization algorithm on the template element's template contents + XML serialization algorithm on the template element's template content (a DocumentFragment), providing the value of inherited ns for the context namespace, map for the namespace prefix map, prefix index for the generated namespace prefix index, and the value of the @@ -1410,7 +1425,7 @@

    Dependencies

    script and template
  • void elements -
  • The template's template contents +
  • The template's template content The DOM specification [[!DOM4]] defines the following terms used in this document: From 7bccda9963fdbc6dd7cdfb90621dffad6d5d2171 Mon Sep 17 00:00:00 2001 From: Travis Leithead Date: Mon, 6 Jun 2016 09:47:19 -0700 Subject: [PATCH 2/3] template content -> template contents --- index.html | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/index.html b/index.html index 83d0aa2..dd48b3f 100644 --- a/index.html +++ b/index.html @@ -259,12 +259,12 @@

    Extensibility

    context element.
  • If the context object is a template element, then let - context object be the template's template content (a + context object be the template's template contents (a DocumentFragment).

    Setting innerHTML on a template element will replace - all the nodes in its template content - (template.content) rather than its children.

    + all the nodes in its template contents + (template.content) rather than its children.

  • Replace all with fragment within the context object. @@ -429,7 +429,7 @@

    Extensibility

    above "afterbegin" and "beforeend" cases. Unlike innerHTML, insertAdjacentHTML will insert the given fragment into a template's children rather than into its - template content.

    + template contents.

  • @@ -909,11 +909,11 @@

    Extensibility

  • If ns is the HTML namespace, and the node's localName matches the string "template", then this is a template element. Append to markup the result of running the - XML serialization algorithm on the template element's template content + XML serialization algorithm on the template element's template contents (a DocumentFragment), providing the value of inherited ns for the context namespace, map for the namespace prefix map, prefix index for the generated namespace prefix index, and the value of the - require well-formed flag. This allows template content to + require well-formed flag. This allows template contents to round-trip , given the rules for parsing XHTML documents.
  • Otherwise, append to markup the result of running the @@ -1425,7 +1425,7 @@

    Dependencies

    script and template
  • void elements -
  • The template's template content +
  • The template's template contents The DOM specification [[!DOM4]] defines the following terms used in this document: From d7931b0f3fa4196c88c12fbbab504ff63f112a81 Mon Sep 17 00:00:00 2001 From: Travis Leithead Date: Tue, 7 Jun 2016 17:44:12 -0700 Subject: [PATCH 3/3] Adjust note on insertAdjacentHTML with cscott's suggestion --- index.html | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/index.html b/index.html index dd48b3f..2f43347 100644 --- a/index.html +++ b/index.html @@ -258,14 +258,14 @@

    Extensibility

    the new value as markup, and the context object as the context element. -
  • If the context object is a template element, then let - context object be the template's template contents (a +
  • If the context object is a template element, then let + context object be the template's template contents (a DocumentFragment). - -

    Setting innerHTML on a template element will replace - all the nodes in its template contents + +

    Setting innerHTML on a template element will replace + all the nodes in its template contents (template.content) rather than its children.

    - +
  • Replace all with fragment within the context object. @@ -424,13 +424,16 @@

    Extensibility

    the context object's next sibling. - -

    No special handling for template elements is included in the - above "afterbegin" and "beforeend" cases. Unlike - innerHTML, insertAdjacentHTML will insert the given - fragment into a template's children rather than into its - template contents.

    - + +

    No special handling for template elements is included in the + above "afterbegin" and "beforeend" cases. As with other direct + Node-manipulation APIs (and unlike innerHTML), + insertAdjacentHTML does not include any special handling for + template elements. In most cases you will wish to use + template.content.insertAdjacentHTML + instead of directly manipulating the child nodes of a template + element.

    +

    Extensions to the Range interface

    @@ -601,8 +604,8 @@

    Extensibility

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

    Per [[DOM4]], Attr objects do not inherit from Node, and thus cannot be serialized by the XML serialization algorithm. An attempt to serialize an @@ -1434,7 +1437,7 @@

    Dependencies

  • The following concepts: case-sensitive and ASCII case-insensitive string comparisons; - a node's children, + a node's children, first child, next sibling and parent; @@ -1533,6 +1536,7 @@

    Acknowledgements

    specification is based.

    Thanks to + C. Scott Ananian, Victor Costan, Aryeh Gregor, Anne van Kesteren,