Skip to content
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

Is it expected that Document has [LegacyOverrideBuiltIns]? #9394

Closed
yuki3 opened this issue Jun 7, 2023 · 2 comments
Closed

Is it expected that Document has [LegacyOverrideBuiltIns]? #9394

yuki3 opened this issue Jun 7, 2023 · 2 comments

Comments

@yuki3
Copy link
Contributor

yuki3 commented Jun 7, 2023

I have a question. Maybe I'm just misunderstanding. Please correct me if I'm wrong.

https://html.spec.whatwg.org/multipage/dom.html#htmlorsvgscriptelement

[LegacyOverrideBuiltIns]
partial interface Document {
...(snip)...

// DOM tree accessors
getter object (DOMString name);

Document interface has [LegacyOverrideBuiltIns] in HTML spec. However, Chromium (Blink) doesn't implement [LegacyOverrideBuiltIns] on window.document nor Document nor HTMLDocument. As far as I tested with Firefox and Safari, Firefox and Safari also look not implementing [LegacyOverrideBuiltIns]. If so, is it really the consensus to have [LegacyOverrideBuiltIns]?

I ran the following JS code on Firefox and Safari JS console. The results were the same on both browsers.

document.foo = 3;
form = document.createElement('form');
form.name = 'foo';

document.foo;  // => 3
document.body.appendChild(form);
document.foo;  // => 3 (not `form`)
delete document.foo;  // => true
document.foo;  // => <form name="foo">
@annevk
Copy link
Member

annevk commented Jun 7, 2023

This was introduced in f355f4a. The rationale seems to start at https://krijnhoetmer.nl/irc-logs/whatwg/20090113#l-261 and gives http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%0D%0A...%3Ciframe%20name%3Dbody%3E%3C%2Fiframe%3E%3Cscript%3Ew(document.body)%3C%2Fscript%3E as an example.

In your test foo is not a builtin so I'm not sure why you expect it to override that?

@yuki3
Copy link
Contributor Author

yuki3 commented Jun 7, 2023

Thanks! I was misunderstanding that [LegacyOverrideBuiltIns] has priority over own properties. It's wrong.
https://webidl.spec.whatwg.org/#dfn-named-property-visibility
explicitly mentions that own properties have priority over anything else regardless of [LegacyOverrideBuiltIns].

My memory was rust. I'm sorry for taking your precious time, and really appreciate you about correcting me. :)

@yuki3 yuki3 closed this as completed Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants