-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
HTMLElement constructor step 5.2 refers to mysterious document #1154
Comments
Thanks for the catch. I see two alternatives:
These will differ after navigation: if you saved the
Consistency with Opinions @rniwa @annevk @smaug----? |
Ideally the same as |
Yeah, DOM's "node document is the global object’s associated document" doesn't exactly define which global (incumbent, entry, current being the possibilities) but it's probably current, which would be (B). (Note to self: I should probably clean up this constructor to use "the current Realm", instead of "GetFunctionRealm(the currently executing HTMLElement function)".) I tested Image in http://software.hixie.ch/utilities/js/live-dom-viewer/?saved=4119 and it turns out that Chrome does (B) for both Image and Text, whereas Firefox does (A) for both Image and Text. Whereas per spec, Text is probably (B), and Image is (A). So I think we have some flexibility here to fix custom elements and Image to match (B). Unless anyone objects, I'll make that change here (and PR DOM to increase clarity), then file some Firefox and Edge bugs. |
BTW it would be good to merge #1091 to give me a solid basis for talking about this stuff in my fix. |
FWIW Blink implements the Text constructor like Image (in Blink bindings, this is governed by the ConstructorCallWith extended attribute.) We don't implement Document constructor yet, but will. |
@bzbarsky the suggestion here is to make the associated document for |
Er.. Firefox does in fact use the current Realm's newest document, option (B) above. In the testcase at http://software.hixie.ch/utilities/js/live-dom-viewer/?saved=4119 the load in the iframe is same-origin, so when it completes the same I modified Domenic's testcase to explicitly check whether the initial |
Er, that testcase with a typo corrected: http://software.hixie.ch/utilities/js/live-dom-viewer/?saved=4122 On http://software.hixie.ch/utilities/js/live-dom-viewer/?saved=4123 (click the button to run the test, yay popup blockers) Chrome seems to do the right thing with initial |
And on http://software.hixie.ch/utilities/js/live-dom-viewer/?saved=4126 Firefox and Chrome also agree: both reuse the Window of the initial They also agree on http://software.hixie.ch/utilities/js/live-dom-viewer/?saved=4124 in that neither one reuses the initial |
OK, so I didn't mean to get the initial about:blank involved; I forgot about the initial load. http://software.hixie.ch/utilities/js/live-dom-viewer/?saved=4129 is a revised version, but still seems to show Chrome using (B) for both Image and Text, and Firefox using (A). (And, it still fails for weird seemingly-unrelated reasons in Edge.) |
http://software.hixie.ch/utilities/js/live-dom-viewer/?saved=4129 is identical to http://software.hixie.ch/utilities/js/live-dom-viewer/?saved=4119 except for the |
Yes, I meant to post something more like http://software.hixie.ch/utilities/js/live-dom-viewer/?saved=4134 This shows both Chrome and Firefox aligning on (B), it seems. There's some other different issue where setting and reading |
Fixes #1154, which originally covered only the undefined "document" variable in the HTMLElement constructor, but expanded on further investigation to reveal that the spec's current choice of node document for Audio, Image, and Option was strange and not implemented in browsers. While there, cleans up all three of these named constructors to correctly use "create an element," and to be in numbered algorithm form instead of giant-prose-block form.
OK. I did tell you that Firefox does (B). ;)
Please do feel free to link me to a testcase showing this problem. It doesn't seem to be showing up on http://software.hixie.ch/utilities/js/live-dom-viewer/?saved=4134 as far as I can tell. |
Fixes #1154, which originally covered only the undefined "document" variable in the HTMLElement constructor, but expanded on further investigation to reveal that the spec's current choice of node document for Audio, Image, and Option was strange and not implemented in browsers. While there, cleans up all three of these named constructors to correctly use "create an element," and to be in numbered algorithm form instead of giant-prose-block form.
Fixes #1154, which originally covered only the undefined "document" variable in the HTMLElement constructor, but expanded on further investigation to reveal that the spec's current choice of node document for Audio, Image, and Option was strange and not implemented in browsers. While there, cleans up all three of these named constructors to correctly use "create an element," and to be in numbered algorithm form instead of giant-prose-block form.
Fixes #1154, which originally covered only the undefined "document" variable in the HTMLElement constructor, but expanded on further investigation to reveal that the spec's current choice of node document for Audio, Image, and Option was strange and not implemented in browsers. While there, cleans up all three of these named constructors to correctly use "create an element," and to be in numbered algorithm form instead of giant-prose-block form; also gives the HTMLElement constructor its own <dfn> and inline some of its steps.
I am trying to implement HTMLElement constructor in Blink. At step 5.2, the part that says “and node document set to document”, I don't know what document refers to.
I think this should follow the behavior of Image, which says: “The element's node document must be the active document of the browsing context of the Window object on which the interface object of the invoked constructor is found.”
Apologies in advance if I am missing something obvious here.
The text was updated successfully, but these errors were encountered: