[Webkit-unassigned] [Bug 42801] New: index setters on Array.prototype not run when index set on array instance
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Wed Jul 21 18:56:02 PDT 2010
https://bugs.webkit.org/show_bug.cgi?id=42801
Summary: index setters on Array.prototype not run when index
set on array instance
Product: WebKit
Version: 528+ (Nightly build)
Platform: All
OS/Version: All
Status: UNCONFIRMED
Severity: Normal
Priority: P2
Component: JavaScriptCore
AssignedTo: webkit-unassigned at lists.webkit.org
ReportedBy: brendan at mozilla.org
CC: oliver at apple.com
>From a SpiderMonkey shell:
js> Array.prototype.__defineSetter__("foo", function() { print("Foo!"); });
js> Array.prototype.__defineSetter__(0, function() { print("Zero!"); });
js> var a = Array();
js> a.foo = 0;
Foo!
js> a[0] = 0;
Zero!
In a JSC shell:
> Array.prototype.__defineSetter__("foo", function() { print("Foo!"); });
undefined
> Array.prototype.__defineSetter__(0, function() { print("Zero!"); });
undefined
> var a = Array();
undefined
> a.foo = 0;
Foo!
0
> a[0] = 0;
0
V8 matches JSC. The __defineSetter__ stuff predates ES5, but ES5 codifies what Mozilla promulgated for __defineSetter__:
8.12.5 [[Put]] ( P, V, Throw )
. . .
1. If the result of calling the [[CanPut]] internal method of O with argument P is false, then
a. If Throw is true, then throw a TypeError exception.
b. Else return.
2. Let ownDesc be the result of calling the [[GetOwnProperty]] internal method of O with argument P.
3. If IsDataDescriptor(ownDesc) is true, then
a. Let valueDesc be the Property Descriptor {[[Value]]: V}.
b. Call the [[DefineOwnProperty]] internal method of O passing P, valueDesc, and Throw as arguments.
c. Return.
4. Let desc be the result of calling the [[GetProperty]] internal method of O with argument P. This may be either an own or inherited accessor property descriptor or an inherited data property descriptor.5. If IsAccessorDescriptor(desc) is true, then
a. Let setter be desc.[[Set]] which cannot be undefined.
b. Call the [[Call]] internal method of setter providing O as the this value and providing V as the sole argument.
5. If IsAccessorDescriptor(desc) is true, then
a. Let setter be desc.[[Set]] which cannot be undefined.
b. Call the [[Call]] internal method of setter providing O as the this value and providing V as the sole argument.
6. Else, create a named data property named P on object O as follows
a. Let newDesc be the Property Descriptor {[[Value]]: V, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true}.
b. Call the [[DefineOwnProperty]] internal method of O passing P, newDesc, and Throw as arguments.
7. Return.
/be
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the webkit-unassigned
mailing list