<?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>21945</bug_id>
          
          <creation_ts>2013-05-06 21:59:35 +0000</creation_ts>
          <short_desc>Does responseXML ever return an XMLDocument</short_desc>
          <delta_ts>2014-05-20 14:41:16 +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>XHR</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>25028</dup_id>
          
          <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="Erik Arvidsson">erik.arvidsson</reporter>
          <assigned_to name="Anne">annevk</assigned_to>
          <cc>bugs</cc>
    
    <cc>bzbarsky</cc>
    
    <cc>esprehn</cc>
    
    <cc>iaflybymight</cc>
    
    <cc>mike</cc>
    
    <cc>Ms2ger</cc>
    
    <cc>public-webapps</cc>
    
    <cc>travil</cc>
    
    <cc>tross</cc>
    
    <cc>zcorpan</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>87290</commentid>
    <comment_count>0</comment_count>
    <who name="Erik Arvidsson">erik.arvidsson</who>
    <bug_when>2013-05-06 21:59:35 +0000</bug_when>
    <thetext>The IDL says Document? but I&apos;m curious if one could check the type of the returned document to determing if it is an HTML Document or an XMLDocument?

For example, it might be useful to know if xhr.responseXML.createElement(&apos;div&apos;) would create an HTMLDivElement or an Element object.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87293</commentid>
    <comment_count>1</comment_count>
    <who name="Elliott Sprehn">esprehn</who>
    <bug_when>2013-05-06 22:33:01 +0000</bug_when>
    <thetext>I think the text in the spec for XMLDocument might explain this:

http://dom.spec.whatwg.org/#xmldocument

&quot;&quot;&quot;A document is assumed to be an XML document unless it is flagged as being an HTML document. Whether a document is an HTML document or an XML document affects the behavior of certain APIs.&quot;&quot;&quot;

So createDocument() returns an XMLDocument if you pass no arguments and an HTMLDocument if you pass the HTML namespace.

So you know createElement will return an HTMLDivElement if responseXML instanceof XMLDocument is false.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87294</commentid>
    <comment_count>2</comment_count>
    <who name="Elliott Sprehn">esprehn</who>
    <bug_when>2013-05-06 22:42:33 +0000</bug_when>
    <thetext>Also note that real world implementations absolutely do return an HTMLDocument or a plain Document (now XMLDocument) based on the content type from responseXML. Gecko, Webkit and Blink all will pick one or the other.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87295</commentid>
    <comment_count>3</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2013-05-06 23:02:44 +0000</bug_when>
    <thetext>The &quot;XML document&quot; and &quot;HTML document&quot; flag thingie is distinct from the interface going around.

As for what document.createElement() does. I recommend reading bug 19431.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87296</commentid>
    <comment_count>4</comment_count>
    <who name="Elliott Sprehn">esprehn</who>
    <bug_when>2013-05-06 23:17:12 +0000</bug_when>
    <thetext>(In reply to comment #3)
&gt; The &quot;XML document&quot; and &quot;HTML document&quot; flag thingie is distinct from the
&gt; interface going around.

Right, so responseXML can be an XMLDocument or an HTMLDocument but createElement will produces HTMLElement instances.

&gt; 
&gt; As for what document.createElement() does. I recommend reading bug 19431.

That thread isn&apos;t clear to me. How do I know if a random document created by document.implementation.createDocument() will produce an HTMLElement or an Element when I do createElement(&apos;div&apos;) ?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87297</commentid>
    <comment_count>5</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2013-05-06 23:23:06 +0000</bug_when>
    <thetext>FWIW, createDocument() always creates a document marked as &quot;XML document&quot;.

That bug is about what document.createElement() should do and whether it should depend on the type of document at all. Currently it only has a few exceptions for &quot;HTML document&quot; flagged document objects, but only with regards to casing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87315</commentid>
    <comment_count>6</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2013-05-07 09:36:40 +0000</bug_when>
    <thetext>(In reply to comment #4)
&gt; Right, so responseXML can be an XMLDocument or an HTMLDocument but
&gt; createElement will produces HTMLElement instances.

No. responseXML can only be Document. HTMLDocument no longer exists (it has been merged with Document). XMLDocument is only returned by the document.createDocument() API. As Anne said, &quot;HTML document&quot; and &quot;XML document&quot; are different concepts.

&gt; That thread isn&apos;t clear to me. How do I know if a random document created by
&gt; document.implementation.createDocument() will produce an HTMLElement or an
&gt; Element when I do createElement(&apos;div&apos;) ?

Currently createElement(&apos;div&apos;) always produces an HTMLDivElement, regardless of the document.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87316</commentid>
    <comment_count>7</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2013-05-07 09:58:41 +0000</bug_when>
    <thetext>(In reply to comment #6)
&gt; Currently createElement(&apos;div&apos;) always produces an HTMLDivElement, regardless
&gt; of the document.
Per spec, but not per implementations. Not sure which one is wrong.
I think spec, but not sure...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87329</commentid>
    <comment_count>8</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-05-07 13:58:43 +0000</bug_when>
    <thetext>&gt; HTMLDocument no longer exists (it has been merged with Document)

Which no one implements in practice and which is not clearly desirable anyway, right?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87335</commentid>
    <comment_count>9</comment_count>
    <who name="Erik Arvidsson">erik.arvidsson</who>
    <bug_when>2013-05-07 15:25:27 +0000</bug_when>
    <thetext>(In reply to comment #8)
&gt; &gt; HTMLDocument no longer exists (it has been merged with Document)
&gt; 
&gt; Which no one implements in practice and which is not clearly desirable
&gt; anyway, right?

FWIW, IE9+ only implements Document. It does not have an XMLDocument nor HTMLDocument.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87354</commentid>
    <comment_count>10</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-05-07 16:30:40 +0000</bug_when>
    <thetext>In IE9 the thing returned from responseXML isn&apos;t even instanceof Document and is otherwise all sorts of weird (toString on it throws, Object.prototype.toString.call returns &quot;[object Object]&quot;, etc, etc).  It certainly doesn&apos;t support various Document stuff from the spec like the named getter and write().

So I guess you could argue that IE has merged Document and HTMLDocument by making only HTML documents be Document.... I&apos;m not sure that&apos;s useful.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87374</commentid>
    <comment_count>11</comment_count>
    <who name="Erik Arvidsson">erik.arvidsson</who>
    <bug_when>2013-05-07 19:41:18 +0000</bug_when>
    <thetext>(In reply to comment #10)
&gt; In IE9 the thing returned from responseXML isn&apos;t even instanceof Document
&gt; and is otherwise all sorts of weird (toString on it throws,
&gt; Object.prototype.toString.call returns &quot;[object Object]&quot;, etc, etc).  It
&gt; certainly doesn&apos;t support various Document stuff from the spec like the
&gt; named getter and write().
&gt; 
&gt; So I guess you could argue that IE has merged Document and HTMLDocument by
&gt; making only HTML documents be Document.... I&apos;m not sure that&apos;s useful.

That was in IE9... In IE10 the following asserts all passes.

var xhr = new XMLHttpRequest;
xhr.open(&apos;GET&apos;, &apos;test.xml&apos;, false);
xhr.send();

assert(Object.prototype.toString.call(xhr.responseXML) === &apos;[object Document]&apos;);
assert(xhr.responseXML instanceof Document);</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87401</commentid>
    <comment_count>12</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-05-08 02:11:22 +0000</bug_when>
    <thetext>Ah, interesting.  Does IE10 support the named getter on such documents?  What does it do with document.write() on them?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87428</commentid>
    <comment_count>13</comment_count>
    <who name="Erik Arvidsson">erik.arvidsson</who>
    <bug_when>2013-05-08 15:14:05 +0000</bug_when>
    <thetext>(In reply to comment #12)
&gt; Ah, interesting.  Does IE10 support the named getter on such documents? 
&gt; What does it do with document.write() on them?

Based on my testing... The MS guys are now subscribed to this bug so they can probably answer these questions better.

* document.write throws (maybe it works during loading of the doc... I didn&apos;t test)

* Named getters works</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106441</commentid>
    <comment_count>14</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-05-20 14:41:16 +0000</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of bug 25028 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>