This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 22960 - Document, XMLDocument, HTMLDocument, oh my
Summary: Document, XMLDocument, HTMLDocument, oh my
Status: RESOLVED MOVED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: DOM (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: Anne
QA Contact: public-webapps-bugzilla
URL:
Whiteboard: blocked on implementers removing cruft
Keywords:
: 25028 27684 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-08-14 16:46 UTC by Erik Arvidsson
Modified: 2016-08-16 08:58 UTC (History)
9 users (show)

See Also:


Attachments

Description Erik Arvidsson 2013-08-14 16:46:55 UTC
The html and dom specs only have Document and XMLDocument. This does not match reality where we actually have HTMLDocument as well.

WebKit/Blink:

XMLDocument === Document // true
HTMLDocument.prototype.__proto__ === Document.prototype  // true
SVGDocument.prototype.__proto__ === Document.prototype  // true

document.implementation.createDocument(null, 'root', null)  // Document
document.implementation.createDocument('http://www.w3.org/1999/xhtml/', 'html', null)  // Document
document.implementation.createDocument('http://www.w3.org/2000/svg', 'svg', null)  // SVGDocument
document.implementation.createHTMLDocument('title')  //  HTMLDocument

Gecko:

XMLDocument.prototype.__proto__ === Document.prototype  // true
HTMLDocument.prototype.__proto__ === Document.prototype  // true
SVGDocument.prototype.__proto__ === Document.prototype  // true

document.implementation.createDocument(null, 'root', null)  // XMLDocument
document.implementation.createDocument('http://www.w3.org/1999/xhtml/', 'html', null)  // XMLDocument
document.implementation.createDocument('http://www.w3.org/2000/svg', 'svg', null)  // XMLDocument
document.implementation.createHTMLDocument('title')  //  HTMLDocument

IE10:

typeof XMLDocument  // 'undefined'
typeof HTMLDocument  // 'undefined'
typeof SVGDocument  // 'undefined'

document.implementation.createDocument(null, 'root', null)  // Document
document.implementation.createDocument('http://www.w3.org/1999/xhtml/', 'html', null)  // Document
document.implementation.createDocument('http://www.w3.org/2000/svg', 'svg', null)  // Document
document.implementation.createHTMLDocument('title')  //  Document

IE11:

XMLDocument.prototype.__proto__ === Document.prototype  // true
HTMLDocument.prototype.__proto__ === Document.prototype  // true
typeof SVGDocument  // 'undefined'

document.implementation.createDocument(null, 'root', null)  // XMLDocument
document.implementation.createDocument('http://www.w3.org/1999/xhtml/', 'html', null)  // XMLDocument
document.implementation.createDocument('http://www.w3.org/2000/svg', 'svg', null)  // XMLDocument
document.implementation.createHTMLDocument('title')  //  HTMLDocument

It is unclear if there is a way to create an SVGDocument in IE and Gecko.
Comment 1 Ian 'Hixie' Hickson 2013-08-20 17:15:06 UTC
The solution here is for the browsers to align with the specs.

It doesn't make sense to have separate SVGDocument and HTMLDocument objects. You can have HTML in SVG and SVG in HTML.
Comment 2 Masatoshi Kimura 2013-08-29 15:13:46 UTC
(In reply to comment #1)
> The solution here is for the browsers to align with the specs.

Virtually all browser vendors disagree with merging:
https://bugzilla.mozilla.org/show_bug.cgi?id=897815
https://code.google.com/p/chromium/issues/detail?id=238368
https://bugs.webkit.org/show_bug.cgi?id=110772
In particular, IE11 reversed the behavior.

> It doesn't make sense to have separate SVGDocument and HTMLDocument objects.
> You can have HTML in SVG and SVG in HTML.

Unfortunately, it's common that browsers are doing something totally nonsensical and the spec will have to document the nonsense.
Comment 3 Ian 'Hixie' Hickson 2013-10-09 19:41:46 UTC
> Virtually all browser vendors disagree with merging:
> https://bugzilla.mozilla.org/show_bug.cgi?id=897815
> https://code.google.com/p/chromium/issues/detail?id=238368
> https://bugs.webkit.org/show_bug.cgi?id=110772

Those bugs are still open. I wouldn't characterise that as disagreeing, just being cautious, as they should with something this drastic. This is the same thing we went through (correctly and appropriately) with the HTML parser.


> > It doesn't make sense to have separate SVGDocument and HTMLDocument objects.
> > You can have HTML in SVG and SVG in HTML.
> 
> Unfortunately, it's common that browsers are doing something totally
> nonsensical and the spec will have to document the nonsense.

Sure, but that's not the only choice. Here in particular it doesn't seem to be the right choice, even.

There's maybe work to do — for see this thread:
   http://lists.w3.org/Archives/Public/public-whatwg-archive/2013Oct/0062.html

But just sticking with the old solution of separate SVGDocumetn and HTMLDocument objects just doesn't work.
Comment 4 Anne 2014-05-20 09:57:36 UTC
*** Bug 25028 has been marked as a duplicate of this bug. ***
Comment 5 Chris Dumez 2014-05-20 12:15:24 UTC
(In reply to Ian 'Hixie' Hickson from comment #3)
> > Virtually all browser vendors disagree with merging:
> > https://bugzilla.mozilla.org/show_bug.cgi?id=897815
> > https://code.google.com/p/chromium/issues/detail?id=238368
> > https://bugs.webkit.org/show_bug.cgi?id=110772
> 
> Those bugs are still open. I wouldn't characterise that as disagreeing, just
> being cautious, as they should with something this drastic. This is the same
> thing we went through (correctly and appropriately) with the HTML parser.

FYI, Blink has already merged SVGDocument into Document:
http://src.chromium.org/viewvc/blink?view=revision&revision=166179

We also started moving attributes from HTMLDocument to Document (even though HTMLDocument still exists for now):
https://code.google.com/p/chromium/issues/detail?id=362955
http://src.chromium.org/viewvc/blink?view=rev&rev=165515
Comment 6 Robin Berjon 2014-12-23 12:51:11 UTC
*** Bug 27684 has been marked as a duplicate of this bug. ***
Comment 7 Anne 2016-08-16 08:58:43 UTC
https://github.com/whatwg/dom/issues/221
https://github.com/whatwg/dom/issues/278

It seems engines are slowly merging these. At the end of that process we might have to do some additional cleanup, but that'll be filed as follow up issues.