Closed Bug 71992 Opened 24 years ago Closed 24 years ago

Getting references to the getter and setter functions

Categories

(Core :: JavaScript Engine, enhancement, P1)

x86
Other
enhancement

Tracking

()

VERIFIED FIXED
mozilla0.9

People

(Reporter: pbwiz, Assigned: brendan)

Details

(Keywords: js1.5)

Attachments

(2 files)

First of all... Great JOB guys. I love what you have done to JavaScript in this version. You all have made it into a powerhouse. The suggestion... I have been playing with the __defineGetter__ and __defineSetter__ functions and I would like to make a suggestion. It would be benificial if you made a method of getting a reference the getter and setter functions for a property, and the ability to over-ride them. I will give you an example: You have a style set on a div element (say the width property) that you want to change in responce to an expression. If you use element.style.__defineGetter__("width", functionRef ) then the value of the element.style.width will return the value of the function referenced, but it will not be reflected in the layout. I would suggest a method such as __getGetter__("propertyName") and __getSetter__ ("propertyName") that would return a reference to this function. Or you may need some other method like __replaceGetter__/__replaceSetter__. The whole point of this is to be able to emulate the setExpression method from IE. This is a very powerful method for dynamic layout. Jeff Yates
cc'ing Brendan, shaver, jst -
Status: UNCONFIRMED → NEW
Ever confirmed: true
I'll take this and supply a patch that adds __lookupGetter__ and __lookupSetter__. /be
Assignee: rogerl → brendan
Brendan, Would __lookupGetter__ and __lookupSetter__ allow you to override them? Or would this be 2 more functions that would have to be added? Don't get me wrong, these two are important even if you did over-ride them so that the method used to over-ride the property may need to call the origional getter/setter functions. Jeff.
Status: NEW → ASSIGNED
Keywords: js1.5, mozilla0.9
Target Milestone: --- → mozilla0.9
I see no need to provide more than the minimum: o.__lookupGetter__('p') returns the getter function for o.p, or undefined if o.p has no getter. Users can wrap and layer. Patch next. /be
Priority: -- → P1
Attached patch proposed fixSplinter Review
Testing and review welcome. rogerl, shaver, how about r= and sr=? /be
I like it. r/sr=shaver. (Man, we should so just expose the whole MOP here.)
r=rogerl
We all flunk the "don't forget to OBJ_DROP_PROPERY after LOOKUP" test ('cept I remembered just now, will the prof give me credit?). /be
Attached patch fixed fixSplinter Review
I think silence is golden here, so returning undefined if there is no such property, or the property has no getter, beats throwing an exception. Comments? /be
I am shamed, and consent to your silence. r=shaver again.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Fix in, but give me a reason (future compatibility?) for throwing instead of returning void? /be
Added testcase to JS testsuite: js/tests/js1_5/GetSet/getset-006.js JS Engine passing testcase on WinNT, Linux. Marking Verified -
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: