<?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>29175</bug_id>
          
          <creation_ts>2015-10-03 02:24:02 +0000</creation_ts>
          <short_desc>Special rules for HTML element in HTML document for Element.insertAdjacentHTML() are necessary?</short_desc>
          <delta_ts>2016-05-05 12:05:35 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>DOM Parsing and Serialization</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Arkadiusz Michalski (Spirit)">crimsteam</reporter>
          <assigned_to name="Travis Leithead [MSFT]">travil</assigned_to>
          <cc>bzbarsky</cc>
    
    <cc>mike</cc>
    
    <cc>www-dom</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>123465</commentid>
    <comment_count>0</comment_count>
    <who name="Arkadiusz Michalski (Spirit)">crimsteam</who>
    <bug_when>2015-10-03 02:24:02 +0000</bug_when>
    <thetext>Firefox is the only current browser which complies these requirements (step 2.)?
http://www.w3.org/TR/DOM-Parsing/#dfn-dom-element-insertadjacenthtml

Small test:

&lt;script type = &quot;text/javascript&quot;&gt;

	var newFragment = document.createDocumentFragment();
	newFragment.appendChild(document.createElement(&quot;html&quot;));
	
	newFragment.firstChild.insertAdjacentHTML(&quot;afterbegin&quot;, &quot;&lt;p&gt;test&quot;);
	alert(newFragment.firstChild.innerHTML);

&lt;/script&gt;

Firefox, IE6/IE7/IE8/ : &lt;p&gt;test&lt;/p&gt;
Chrome, IE11, Opera (Presto): &lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;p&gt;test&lt;/p&gt;&lt;/body&gt;

I don&apos;t have access to Safari, what WebKit returns? What Edge returns?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123475</commentid>
    <comment_count>1</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2015-10-05 03:20:46 +0000</bug_when>
    <thetext>&gt; what WebKit returns?

Same thing as Chrome and IE11.

&gt; What Edge returns?

Again, the same thing as Chrome and IE11, as far as I can tell.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>126335</commentid>
    <comment_count>2</comment_count>
    <who name="Arkadiusz Michalski (Spirit)">crimsteam</who>
    <bug_when>2016-05-05 11:49:34 +0000</bug_when>
    <thetext>Basically this step 2. is correct in other browsers excluding one case (when we invoke method on &lt;html&gt; whose parent is DocumentFragment) because they don&apos;t change context to &lt;body&gt;, like we see in https://www.w3.org/Bugs/Public/show_bug.cgi?id=29175#c0.

But in other site actuall definitions in P&amp;S are consistent because fit to Element.outerHTML and Range.createContextualFragment() in simillar cases (when used on &lt;html&gt; as object context). For this commands Firefox is still correct, other browsers are more or less correct (they have other inaccuracies).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>126336</commentid>
    <comment_count>3</comment_count>
    <who name="Arkadiusz Michalski (Spirit)">crimsteam</who>
    <bug_when>2016-05-05 12:05:35 +0000</bug_when>
    <thetext>And small test:

&lt;script type = &quot;text/javascript&quot;&gt;
	var range = document.createRange();
	var newFragment = document.createDocumentFragment();
	newFragment.appendChild(document.createElement(&quot;html&quot;));
	range.setStart(newFragment.firstChild, 0);
	alert(new XMLSerializer().serializeToString(range.createContextualFragment(&quot;&lt;p&gt;test&quot;)));

	newFragment = document.createDocumentFragment();
	var html = document.createElement(&quot;html&quot;);
	var head = document.createElement(&quot;head&quot;);
	html.appendChild(head);
	newFragment.appendChild(html);
	head.outerHTML = &quot;&lt;p&gt;aaa&quot;;
	alert(new XMLSerializer().serializeToString(newFragment));

	// Chrome throw here so I put this test at the end
	newFragment = document.createDocumentFragment();
	newFragment.appendChild(document.createElement(&quot;html&quot;));
	newFragment.firstChild.outerHTML = &quot;&lt;p&gt;test&quot;;
	alert(new XMLSerializer().serializeToString(newFragment));
&lt;/script&gt;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>