Closed
Bug 2036318
Opened 17 days ago
Closed 12 days ago
ObservableArray has null prototype but still behaves like an Array
Categories
(Core :: DOM: Bindings (WebIDL), defect)
Core
DOM: Bindings (WebIDL)
Tracking
()
RESOLVED
FIXED
152 Branch
| Tracking | Status | |
|---|---|---|
| firefox152 | --- | fixed |
People
(Reporter: robwu, Assigned: robwu)
References
Details
Attachments
(1 file)
|
48 bytes,
text/x-phabricator-request
|
Details |
An ObservableArray has a null prototype in Firefox (Array.prototype in Chrome and Safari):
console.log(document.adoptedStyleSheets.__proto__); // null
console.log(Object.getPrototypeOf(document.adoptedStyleSheets)); // null
Yet is still inherits from Array.prototype:
Array.prototype.customPush = function (s) { return this.push(s); };
sheet = new CSSStyleSheet();
sheet.replaceSync("*{background:pink}");
document.adoptedStyleSheets.customPush(sheet); // page turns pink
Even after replacing its prototype, methods are still exposed from Array.prototype instead of whatever the prototype was set to (but somehow DevTools' autocompletion suggests method from the specified prototype):
Array.prototype.customPush2 = function (s) { return this.push(s); };
Object.setPrototypeOf(document.adoptedStyleSheets, { test: 1 });
console.log(document.adoptedStyleSheets.__proto__); // { test: 1 }
console.log(document.adoptedStyleSheets.test); // undefined (1 in Chrome+Safari)
console.log(document.adoptedStyleSheets.customPush2); // function (undefined in Chrome+Safari)
sheet = new CSSStyleSheet();
sheet.replaceSync("*{background:red}");
document.adoptedStyleSheets.customPush2(sheet); // page turns red (error in Chrome+Safari)
I found this while looking at bug 1751346; this is a follow-up to https://phabricator.services.mozilla.com/D291049#10323557
| Assignee | ||
Comment 1•16 days ago
|
||
Updated•16 days ago
|
Assignee: nobody → rob
Status: NEW → ASSIGNED
Updated•16 days ago
|
Severity: -- → S3
Pushed by rob@robwu.nl:
https://github.com/mozilla-firefox/firefox/commit/b0f3671e754b
https://hg.mozilla.org/integration/autoland/rev/934066f82a0f
Specify prototype for observable arrays r=jandem
Comment 3•12 days ago
|
||
| bugherder | ||
Status: ASSIGNED → RESOLVED
Closed: 12 days ago
status-firefox152:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → 152 Branch
You need to log in
before you can comment on or make changes to this bug.
Description
•