RESOLVED DUPLICATE of bug 12721 26127
__defineSetter__/__defineGetter__ is ignored on native properties
https://bugs.webkit.org/show_bug.cgi?id=26127
Summary __defineSetter__/__defineGetter__ is ignored on native properties
T. Brains
Reported 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.
Attachments
test case (183 bytes, text/html)
2009-06-04 04:07 PDT, Alexey Proskuryakov
no flags
T. Brains
Comment 1 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"); } });
Alexey Proskuryakov
Comment 2 2009-06-04 04:07:26 PDT
Created attachment 30941 [details] test case Same test, as an attachment.
Alexey Proskuryakov
Comment 3 2009-06-04 04:10:37 PDT
*** This bug has been marked as a duplicate of 12721 ***
Note You need to log in before you can comment on or make changes to this bug.