-
Notifications
You must be signed in to change notification settings - Fork 286
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
Change .createElement() namespace to match UAs #213
Conversation
Fixes https://www.w3.org/Bugs/Public/show_bug.cgi?id=19431 See comments 12 and 20 there. Gecko tried switching to the spec's current wording and immediately had to back out due to extension breakage. It does not seem likely the current spec is implementable.
As far as I can tell @domenic since you touched this last, any concerns? |
This is bizarre, but I guess it's what every browser does. I don't think extension-related breakage is a good reason (extensions are vendor-specific and not part of the web), but if this is what everyone implements that's a good enough reason I guess. Here is what Blink does: https://code.google.com/p/chromium/codesearch#chromium/src/third_party/WebKit/Source/core/dom/Document.cpp&q=createElement&sq=package:chromium&l=716 The setting of "document class flags" is done pretty far away in the code base, but maybe .contentType is a good enough proxy. |
@foolip can you confirm for Blink? |
Yes, I checked yesterday and pondered whether The
Having the concept of "HTML or XHTML document" might be useful. |
@annevk What question didn't seem answered in the bug? |
@ayg the one about |
@foolip yeah, if we change some of those APIs to use these concepts in the specifications we should consider introducing it I think. Something to keep in mind. |
@annevk http://w3c-test.org/dom/nodes/Document-createElement-namespace.html seems to test image/svg+xml, and comment 12 seems to indicate that browsers matched the proposed spec. |
Oh, I missed that it was tested, thanks. Anyway, I was already fine with this change 😊. I'll land it later today. |
It occurs to me that one peculiarity of using content type is that if you use createDocument() to create an (X)HTML document, it will have a content type of application/xml per spec, which maybe is not what we want? Is there a better way to say "HTML or XHTML document"? Chrome's createDocument() actually seems to set contentType based on the namespace, so it will behave as expected here. Perhaps it would make sense to change createDocument() to match Chrome, and then this issue goes away. |
Good point @ayg, I remember now that this has come up before, but I'd forgotten it. Per spec "application/xml" is the default and it's never overridden, but Blink indeed does special case the XHTML and SVG namespaces. (So much about Document and its subinterfaces is subtly wrong per spec, so much to sort out...) |
Gecko goes even further and for |
Any infos what Edge or WebKit set for console.log(document.implementation.createDocument("http://www.w3.org/1999/xhtml", "html", null).contentType);
console.log(document.implementation.createDocument("http://www.w3.org/2000/svg", "svg", null).contentType);
console.log(document.implementation.createDocument("http://www.w3.org/1998/Math/MathML", "math", null).contentType); Firefox and Opera(Presto): |
|
Oh, I should post there, thx to redirect. |
I don't know why the current spec would be web compatible. At least it is against what many implementations do |
Fixes https://www.w3.org/Bugs/Public/show_bug.cgi?id=19431
See comments 12 and 20 there. Gecko tried switching to the spec's
current wording and immediately had to back out due to extension
breakage. It does not seem likely the current spec is implementable.