-
Notifications
You must be signed in to change notification settings - Fork 165
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
Consider removing call to named property setter in legacy platform object [[Set]] #630
Comments
Hmm. It's possible this [[Set]] algorithm was written or changed after the Gecko implementation. I don't remember the exact history here. It's worth looking up the history of this part of the spec to see what the reasoning for it was, exactly. |
I think the last major change to the Gecko implementation was https://bugzilla.mozilla.org/show_bug.cgi?id=987007 (April 2014). The spec was written in #45 (March 2015). |
Ah, so the key question is how named creators (aka setters nowadays) should work. I think in Gecko if you do the thing on an [OverrideBuiltins] object (e.g. DOMStringMap) the behavior would be "foo", not "undefined"... |
Hmm, indeed. The test below doesn't call proto.[[Set]], and just calls the setter. Should I just add a check for <!DOCTYPE html>
<script>
var ds = document.documentElement.dataset;
var a = new Proxy(Object.getPrototypeOf(ds), {
set(...args) { w(args); return false; },
});
Object.setPrototypeOf(ds, a);
ds.x = "foo";
w(ds.x)
</script>
|
I confused myself again; it looks like WebKit is following the spec in all cases I tested. Results:
Testsno [OB], O = Receiver<!DOCTYPE html>
<script>
sessionStorage.clear()
var a = new Proxy(Object.getPrototypeOf(sessionStorage), {
set(...args) { w(args); return false; },
});
Object.setPrototypeOf(sessionStorage, a);
sessionStorage.x = "foo";
w(sessionStorage.x)
</script>
no [OB], O ≠ Receiver<!DOCTYPE html>
<script>
sessionStorage.clear()
var a = new Proxy(Object.getPrototypeOf(sessionStorage), {
set(...args) { w(args); return false; },
});
Object.setPrototypeOf(sessionStorage, a);
Object.create(sessionStorage).x = "foo";
w(sessionStorage.x)
</script>
[OB], O = Receiver<!DOCTYPE html>
<script>
var ds = document.documentElement.dataset;
var a = new Proxy(Object.getPrototypeOf(ds), {
set(...args) { w(args); return false; },
});
Object.setPrototypeOf(ds, a);
ds.x = "foo";
w(ds.x)
</script>
[OB], O ≠ Receiver<!DOCTYPE html>
<script>
var ds = document.documentElement.dataset;
var a = new Proxy(Object.getPrototypeOf(ds), {
set(...args) { w(args); return false; },
});
Object.setPrototypeOf(ds, a);
Object.create(ds).x = "foo";
w(ds.x)
</script>
|
… interfaces This is the case where it makes most sense, since the prototype chain can't shadow any properties. This change does not affect normal usage; it is only detectable by messing with the prototype of the object. The majority of implementations (Gecko and Chrome) already follow the proposed change; WebKit follows the existing spec. Fixes #630.
… interfaces This is the case where it makes most sense, since the prototype chain can't shadow any properties. This change does not affect normal usage; it is only detectable by messing with the prototype of the object. The majority of implementations (Gecko and Chrome) already follow the proposed change; WebKit follows the existing spec. Fixes #630.
Test:
Gecko and Chrome call proto.[[Set]]() rather than taking the early return, as shown by the log:
but WebKit may be following the spec:
The text was updated successfully, but these errors were encountered: