Bug 26127 - __defineSetter__/__defineGetter__ is ignored on native properties
Summary: __defineSetter__/__defineGetter__ is ignored on native properties
Status: RESOLVED DUPLICATE of bug 12721
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore JavaScript (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-01 20:08 PDT by T. Brains
Modified: 2009-06-04 04:10 PDT (History)
1 user (show)

See Also:


Attachments
test case (183 bytes, text/html)
2009-06-04 04:07 PDT, Alexey Proskuryakov
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description T. Brains 2009-06-01 20:08:46 PDT
When trying to attach a getter/setter to a native DOM property on an element, the getter/setter seems to be ignored and is never called. The original behavior is maintained.

Use this simple code testcase:

<div id="d"></div>
<script type="text/javascript">
var o=document.getElementById("d");

o.__defineSetter__("id",function () { alert("SET"); });

o.id="test";
</script>

Expected behavior: an alert saying "SET".
Actual behavior: nothing.

The same code works as expected in Firefox and Chrome.

Similarly, attaching the getter/setter on the prototype (for example, on HTMLDivElement.prototype) fails on Safari and Chrome as well, but works as expected in Firefox.
Comment 1 T. Brains 2009-06-01 20:34:06 PDT
It's worth noting that this testcase also works as expected in Opera, and the same functionality can be achieved in IE8 using their getter/setter syntax:

Object.defineProperty(o, "id", { set: function () { alert("SET"); } });

/* or */

Object.defineProperty(HTMLDivElement.prototype, "id", { set: function () { alert("SET"); } });
Comment 2 Alexey Proskuryakov 2009-06-04 04:07:26 PDT
Created attachment 30941 [details]
test case

Same test, as an attachment.
Comment 3 Alexey Proskuryakov 2009-06-04 04:10:37 PDT

*** This bug has been marked as a duplicate of 12721 ***