WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED CONFIGURATION CHANGED
36423
Object.defineProperty cannot be used to set id of Div element, Element/HTMLDivElement prototype
https://bugs.webkit.org/show_bug.cgi?id=36423
Summary
Object.defineProperty cannot be used to set id of Div element, Element/HTMLDi...
T. Brains
Reported
2010-03-20 22:45:33 PDT
Created
attachment 51241
[details]
Object.defineProperty cross-browser testcase In contrast with the implementation in IE8+ and FF3.7, WebKit ignores properties which collide with native properties on DOM prototypes, and throws an error when trying to define any property on a DOM element. This was tested against WebKit nightly
r56152
, Mozilla Developer Preview 3.7 alpha 3, Internet Explorer 8 and Internet Explorer Platform Preview 1.9.7745.6019.
Attachments
Object.defineProperty cross-browser testcase
(1.29 KB, text/html)
2010-03-20 22:45 PDT
,
T. Brains
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
Oliver Hunt
Comment 1
2010-03-21 13:35:56 PDT
Trying to override the getter on the prototype of an element is somewhat pointless as WebKit does not use getters for DOM properties. Technically we could make it do so, but that basically means throwing away performance for no good reason.
T. Brains
Comment 2
2010-03-21 14:23:58 PDT
That means there's absolutely no way to override or extend the default get or set behavior of any of the built-in DOM properties, which is very limiting, and like I mentioned contradicts the behavior of other browsers.
Oliver Hunt
Comment 3
2010-03-21 14:28:16 PDT
(In reply to
comment #2
)
> That means there's absolutely no way to override or extend the default get or > set behavior of any of the built-in DOM properties, which is very limiting, and > like I mentioned contradicts the behavior of other browsers.
What is a use case for overriding "id", etc? Understand that for you to have this misfeature then the DOM must be slowed down for all other uses.
Alfonso Martínez de Lizarrondo
Comment 4
2011-07-31 11:34:58 PDT
A use case for overriding a native property is described here:
http://alfonsoml.blogspot.com/2009/09/hooking-textareavalue-with-ckeditor.html
By overriding the "value" of a textarea, it's possible to use CKEditor but at the same time keep using the same scripts on the page that used to work with plain textareas. Sure, it's not a ground breaking feature, but it can be nice to have, because based on this feature it could be possible to map even more properties to make the use of existing code integrate automatically with CKEditor. Currently if anyone uses the provided script they must tell their users that Safari isn't supported. It can try to be fast, but it doesn't do the job that it's expected to do.
T. Brains
Comment 5
2012-03-12 10:34:15 PDT
Won't this be fixed now under
Bug 49739
?
Gavin Barraclough
Comment 6
2012-03-12 11:01:13 PDT
(In reply to
comment #5
)
> Won't this be fixed now under
Bug 49739
?
I wasn't sure! - assuming that 'id' should be further up the prototype chain than the Element prototype, then I guess so. Since this bug was about more than just direct properties on instances I was conservative & decided not to dupe, but I think you're probably right, it probably is just the same issue.
Ken Jackson
Comment 7
2012-05-29 16:53:00 PDT
I've had similar problems in trying to define a getter for the 'src' attribute of DOM img elements without using prototypes. Many DOM elements have property descriptors where configurable is set to false in webkit/JSC. Note that in Safari 5.1.6, the 3rd test from
comment #1
:
> // Override the property on a DIV element > // PASS: IE8, IE9, FF3.7 > // FAIL: WebKit > try { > Object.defineProperty(el,"id",{ get:function () { return "c"; } }); > alert(el.id==="c" ? "PASS" : "FAIL"); > } catch (e) { > alert("ERROR: "+e.message); > }
fails and displays an alert "ERROR: Attempting to change access mechanism for an unconfigurable property" and this test does not use the prototype chain. This test passes in IE8, IE9, FF3.7 and Chrome 19.0.1084.52. Object.getOwnPropertyDescriptor(el, 'id').configurable returns false in Safari 5.1.6 for this test but returns true in other browsers. It would be nice if webkit/JSC behaved in a manner that was consistent with other browsers.
Ahmad Saleem
Comment 8
2022-05-30 15:01:09 PDT
I just tried the attached test case with Safari 15.5 and it shows "Pass" for all sub-test cases (four times dialog popped-up) similar to other browsers like Firefox Nightly 102 and Chrome Canary 104. Should this be marked as "Resolved Fixed" or "Resolved Invalid". Thanks!
Alexey Proskuryakov
Comment 9
2022-05-31 10:29:41 PDT
Thank you for checking!
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug