-
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
Un-merge Document and HTMLDocument #221
Comments
Note that my serious reservations are not based on data, but rather on lack of data. I could be convinced that this is ok, with actual data and analysis... |
There has been some efforts to move things from Of what remains I think that only I don't have time to spend on this right now, but if it'll get reverted in the spec I'd like a chance to try out the final changes in Blink, so let me know if there's a deadline. |
Right, moving particular APIs to Document might well make a lot of sense. Even moving them all might make sense. What doesn't make sense to me is doing the move in a single commit with no attempt to do per-property analysis. |
So how about this: leave the spec as-is for now, start moving properties to Document on a per-case basis, and if we find any properties we don't want to try moving, change the spec to reintroduce HTMLDocument with those properties. Sound good to everyone? |
Yep, that sounds good. I'm pretty optimistic about Blink being able to make |
Okay, so let's all try that. |
What's the benefit of merging HTMLDocument into Document? Do we really want various HTML-specific attributes / operations to be exposed on non-HTML documents? This is a risky change compatibility-wise and major browser engines all had (and still have) HTMLDocument. This has been in the specification for years and yet no major browser has not implemented it yet. I personally do not understand the benefits of this change but even if there are benefits, is it really worth the trouble / risk for all browser engines? I know I am not inclined to do this change in WebKit. |
Missing not in the last sentence? In Blink most of what was in HTMLDocument has already been moved to Document, see #221 (comment). The set of things that are in HTMLDocument in Gecko and WebKit is not aligned. In Edge, where the IDL files aren't available, I see that In other words, it looks like Edge has already moved everything to Document. @cdumez, what do you think would be a reasonable thing to attempt to converge on? Based on the above, I think the most tractable path with relatively low risk is to move everything into Document, but then leave HTMLDocument an empty interface just like XMLDocument. |
Yes, I was missing a 'not' in my last sentence. It is now fixed. It is interesting that Edge made did change, I was not aware. I guess moving everything to Document while keeping an empty HTMLDocument is relatively low risk as you say. I guess I am just not clear yet on the benefits of doing this. |
@annevk will know, but probably the original motivation was that it's possible to insert any element into any document, so having a type of the document itself doesn't achieve much. Also, I think, to reduce gratuitous differences between XHTML (XMLDocument) and HTML. (Some algorithms still have different behavior based on the document type, though.) Whatever the history, we're now in a weird state and need to plot a course towards interop. Does at least trying to make HTMLDocument empty seem reasonable? Given the changes already made in Blink and Edge, this is very likely web compatible. Whether to attempt the final step of aliasing I don't know. If we don't, we may need to rethink the Document constructor, perhaps instead making it such that HTMLDocument and XMLDocument are the only possible instances. |
I am curious to know what Firefox is planning to do. If Firefox goes in this direction as well then WebKit would likely follow. So far, Gecko and WebKit are mostly in agreement. |
@smaug----, can you comment on Gecko plans? |
I agree with bz. We need to do this per property, not all at once. And while doing it, it is possible that we figure out the merge isn't really possible. We don't really know the behavior of the stuff Edge has. Does Edge still have HTMLDocument interface? What is the prototype chain of an (html) document? I'm tiny bit worried about stuff like open/write/close for example: do they work as expect with SVG or Mathml or such? |
We moved it in smaller parts in Blink as well. Testing what others do makes sense for each step. It seems pretty likely that it's web compatible to move everything, so the question is what you'd like to attempt to do in Gecko.
Edge still has an HTMLDocument interface, and an instance has the expected prototype chain HTMLDocument : Document : Node : EventTarget.
In Blink, these and In Edge, it looks like So there's still some interop work to do here... Finally, one thing that could go badly here if we all aim to make HTMLDocument and XMLDocument aliases of Document is that one or two engines succeed, but the next to try runs into engine-specific troubles similar to that around Gecko's |
I am working on moving some properties from HTMLDocument to Document in WebKit. I am focusing on the properties that Blink has already moved and that I think make sense to have on Document (i.e. do not throw if called on anything else than an HTML document). Since I don't anticipate HTMLDocument going away entirely anytime soon. I don't think it makes sense to move to Document attributes / operations that work only on HTML documents (e.g. open/close/write/writeln). |
If some engines can't move one or two properties, the easiest solution would be to just move those back to HTMLDocument in the spec. As long as we have interop, it doesn't really matter where the properties are, so take the path of least resistance. |
Here is the current situation: So the only difference between Chrome and WebKit at the moment are the following properties: As I said before, I did not move them on purpose because it seems the expected behavior is for them to throw when calling on anything else than an HTMLDocument. Given this behavior and the fact that we still have an HTMLDocument interface in WebKit, I see little point in moving them up to Document. My hope is that an HTMLDocument interface is re-introduced in the HTML specification for the properties that are not useful on other types of documents (and legacy HTMLDocument attributes such as alinkColor since I don't think we want to expose legacy properties or more document types). |
If we add it back we need to be very clear which contexts end up creating it although I suppose that is the case already due to "HTML document"… |
Some thoughts on the WebKit ToT list from #221 (comment)
At the end of the day, I don't feel strongly about any of these, any course of action that would get us to interop would be fine. The missing piece here is what to do about the |
I did a little bit of research with
It's immediately clear that @rafaelw, I didn't look too closely, but I take it this code actually matters for getting the correct behavior in both XML and HTML documents? Copies of this code seem to dominate the usage. http://cdn.clicktale.net/www/ChangeMonitor-latest.js showed up a lot but seems to include an older version of mutation-summary. Given the volume of results, I'd be cautious about changing the truthyness of As for XMLDocument, after checking the most common URL patterns I couldn't find anything that seemed like it would break. So I'd give better odds to making XMLDocument an alias of Document, but that's not a good idea as long as Gecko needs |
#308 is also relevant. I realized that "object HTMLDocument" and "object XMLDocument" are also relevant for compat. I find 606 instances of "object HTMLDocument" and 9243 instances of "object XMLDocument". I didn't dig deeply, but a lot of the latter seems to be MooTools: Sigh. |
In #221 (comment) I said "Not sure how risky the final step of making After #221 (comment) I'm a lot more cautious, and I think we should actually just revive |
@foolip that comment doesn't give an argument for reviving HTMLDocument. Being an alias preserves |
Yes, but it'd also start "working" for things that aren't currently It's possible that it's safe because the code doesn't actually run in any non-HTML documents, but it'd require more analysis. |
Right, my impression is that there are very few non-HTML documents out there, and people are just using it as a test that something is a document (and not, say, any other kind of node). But that is an assumption. |
Gecko seems to be alone in doing that right now. I think the split between |
Edge and I think Safari (https://trac.webkit.org/changeset/218437/webkit) moved all properties from HTMLDocument to Document, I plan to do the same in Blink: |
This has caused a bit of confusion in #551. As long as this is unresolved the specification ought to contain a reference to this issue with a note mentioning that it does not necessarily reflect reality at the moment. |
Though maybe if Chrome, Edge, and Safari have indeed shipped what the specification suggests and there's no longer a distinct HTMLDocument class this has indeed happened now (except in Firefox). I guess we still have a distinct XMLDocument class, but that's okay. |
Yes, Edge matches the spec here (although we haven't removed the actual HTMLDocument interface)
|
Per current spec, document should stringify to "[object Document]". Work to remove "HTMLDocument" is tracked in whatwg/dom#221.
For reference, Mozilla is working on the move like in bug 1415588 |
This is probably a duplicate of whatwg/html#4792. |
It needs to be tracked here as well, as it'll affect |
That’s how engines have been handling it since forever. |
That's not how that works. Internal concepts are separate from the public class. And yes, it's known that there's a mismatch with implementations there, and as part of fixing that, this needs fixing. |
Since |
Pretty sure there is one already. |
This class is currently not in the spec, but it *is* still in all the major browser engines. For compatibility reasons, let's do what other engines do. There is discussion about bringing HTMLDocument back into specs: - whatwg/html#4792 - whatwg/dom#221
This class is currently not in the spec, but it *is* still in all the major browser engines. For compatibility reasons, let's do what other engines do. There is discussion about bringing HTMLDocument back into specs: - whatwg/html#4792 - whatwg/dom#221
Does anyone object? It's been years, nobody has done it, it's claimed that IE did it and then un-did it. Boris has serious reservations about web-compatibility. Is there any actual reason to merge them? Obviously, it makes sense to keep APIs on Document where reasonable, but I don't see why it needs to be wholesale.
The text was updated successfully, but these errors were encountered: