Bug 54289 - Object.defineProperty does not override existing properties
: Object.defineProperty does not override existing properties
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore
: 528+ (Nightly build)
: Macintosh Intel Mac OS X 10.6
: P2 Normal
Assigned To: Nobody
Depends on:
  Show dependency treegraph
Reported: 2011-02-11 09:27 PST by Jürg Lehni
Modified: 2012-03-12 16:00 PDT (History)
2 users (show)

See Also:

Code to replicate behavior. (377 bytes, text/html)
2011-02-11 09:28 PST, Jürg Lehni
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jürg Lehni 2011-02-11 09:27:40 PST
Even if configurable: true was provided at definition time:

var obj = {};

Object.defineProperty(obj, 'test', { value: 10, configurable: true });

alert(obj.test); // 10

Object.defineProperty(obj, 'test', { value: 20, configurable: true });

alert(obj.test); // Should be 20, is still 10

The workaround is to call delete before the 2nd definition:

delete obj.test;

But it seems this contradicts the specifications. Or am I misinterpreting them?
Comment 1 Jürg Lehni 2011-02-11 09:28:29 PST
Created attachment 82140 [details]
Code to replicate behavior.
Comment 2 Jürg Lehni 2011-02-14 02:22:15 PST
Here the link to the same bug over at the Chromium site:

Comment 3 Gavin Barraclough 2012-03-12 16:00:28 PDT
This works in ToT, a lot of defineOwnProperty bugs were fixed lately so it'll be hard to track down exactly which revision!  Please reopen if you are still seeing any issues.

cheers, G.