<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>26837</bug_id>
          
          <creation_ts>2014-09-17 19:01:36 +0000</creation_ts>
          <short_desc>The spec has an example using cloneNode. It would be nice to have another example using just appendChild, similar to this one: http://www.html5rocks.com/en/tutorials/webcomponents/template/#toc-using</short_desc>
          <delta_ts>2014-09-29 21:18:50 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>HTML</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>other</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>https://html.spec.whatwg.org/#the-template-element</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>contributor</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>denilsonsa</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>111704</commentid>
    <comment_count>0</comment_count>
    <who name="">contributor</who>
    <bug_when>2014-09-17 19:01:36 +0000</bug_when>
    <thetext>Specification: https://html.spec.whatwg.org/multipage/scripting.html
Multipage: https://html.spec.whatwg.org/multipage/#the-template-element
Complete: https://html.spec.whatwg.org/#the-template-element
Referrer: https://html.spec.whatwg.org/multipage/scripting-1.html

Comment:
The spec has an example using cloneNode. It would be nice to have another
example using just appendChild, similar to this one:
http://www.html5rocks.com/en/tutorials/webcomponents/template/#toc-using

Posted from: 187.1.80.162
User agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.94 Safari/537.36</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112144</commentid>
    <comment_count>1</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-09-24 22:23:51 +0000</bug_when>
    <thetext>I assume you mean importNode(), not appendChild().

I don&apos;t really understand why you would use importNode(). It&apos;s exactly the same as cloneNode(), except requires more code. Can you elaborate?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112153</commentid>
    <comment_count>2</comment_count>
    <who name="Denilson Figueiredo de Sá">denilsonsa</who>
    <bug_when>2014-09-24 22:49:16 +0000</bug_when>
    <thetext>Indeed, I meant importNode().

As a web developer, I usually read the specs to understand how to use the technologies correctly. And I got confused why cloneNode() is mentioned in the example, while importNode() is used in that other tutorial. I didn&apos;t know which one was correct, or if they were equivalent.

Considering the &lt;template&gt; element creates another Document to hold its contents, I got confused if importNode was required.

This is why I have suggested to add another example (or a comment) showing that they are equivalent.

Thanks for your concern!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112188</commentid>
    <comment_count>3</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-09-25 18:03:03 +0000</bug_when>
    <thetext>I can add a note saying that some authors prefer importNode() but that they are actually identical, sure.

   target.appendChild(document.importNode(node, true))

...is exactly identical to:

   target.appendChild(node.cloneNode(true))

The only difference between cloneNode and importNode is that importNode also changes the ownerDocument, but the ownerDocument gets adjusted by appendChild anyway.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112420</commentid>
    <comment_count>4</comment_count>
    <who name="">contributor</who>
    <bug_when>2014-09-29 21:18:50 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r8825.
Check-in comment: Add a comment about cloneNode vs importNode in the example that clones a template, since some tutorials use importNode instead of cloneNode (they&apos;re identical in practice)
https://html5.org/tools/web-apps-tracker?from=8824&amp;to=8825</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>