-
Notifications
You must be signed in to change notification settings - Fork 295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarify what Document constructor does? #137
Comments
Now it's clear, constructor Document() return new Document object (it's still XML document so internal state is "xml", what is default value and we don't need to mention about this). Remember that document has default value for its internal state and if they are not change (when we construct this document) then DOM (or other spec) don't need mention about it every time (https://dom.spec.whatwg.org/#concept-document-base-url). Firefox supports this constructor in correct way: https://bugzilla.mozilla.org/show_bug.cgi?id=1017932 HTML spec (and some other spec) add next stuff for Document interface and they are available for all documents (HTML/XHTML/XML) but it doesn't mean you can use all of them in all documents without any problem. Please try analize document.write method (https://html.spec.whatwg.org/multipage/webappapis.html#dom-document-write) , when you invoke this method in XML document then you get error (step 1.), but this method still exist in Document object. What actually interfaces are returned by the browsers when we using various constructing methods is known bug (still under consideration in which direction to go further with this): |
Thank you very much for the links. I didn't entirely understood the reasoning behind the change, though. Why was unifying the interfaces necessary? |
Because, due to HTM5, we can use SVG and MathML in X(HT)ML and vice versa, so therefore there is no need to maintain separate SVGDocument and MathMLDocument interface. We can leave only Document with some limitation for different commands (if necessary). In theory this should simplify the further development of specifications, but practice will show if browses will go in this direction. There are other concerns that need to be addressed: XMLDocument still exist because compatibility reason, although in future it may disappear: |
As @ArkadiuszMichalski explained these are all the same. |
Hi everyone and merry xmas!
What is supposed to do the Document constructor? (I'm likely failing at understanding)
If it's not a XMLDocument, is it an HTML Document, then? Or is it an xml document which was just constructed differently? (XMLDocument doesn't add members to the interface)
basically, what are its "type" and "mode" properties set to, since the constructor doesn't have parameters?
The HTML spec adds functionality to Document but it contains members that are only suited to HTML Documents.
Also, in the HTML spec
window.HTMLDocument
is just an alias forwindow.Document
, but all UAs have an actualHTMLDocument
class (as in DOM2, with the exception of MSIE9, which only hasDocument
. Newer MS browsers all haveHTMLDocument : Document
)Thank you in advance.
The text was updated successfully, but these errors were encountered: