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)
Tracking
()
VERIFIED
FIXED
mozilla0.9
People
(Reporter: pbwiz, Assigned: brendan)
Details
(Keywords: js1.5)
Attachments
(2 files)
2.41 KB,
patch
|
Details | Diff | Splinter Review | |
2.59 KB,
patch
|
Details | Diff | Splinter Review |
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
Assignee | ||
Comment 2•24 years ago
|
||
I'll take this and supply a patch that adds __lookupGetter__ and __lookupSetter__.
/be
Assignee: rogerl → brendan
Reporter | ||
Comment 3•24 years ago
|
||
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.
Assignee | ||
Updated•24 years ago
|
Assignee | ||
Comment 4•24 years ago
|
||
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
Assignee | ||
Comment 5•24 years ago
|
||
Assignee | ||
Comment 6•24 years ago
|
||
Testing and review welcome. rogerl, shaver, how about r= and sr=?
/be
Comment 7•24 years ago
|
||
I like it. r/sr=shaver.
(Man, we should so just expose the whole MOP here.)
Comment 8•24 years ago
|
||
r=rogerl
Assignee | ||
Comment 9•24 years ago
|
||
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
Assignee | ||
Comment 10•24 years ago
|
||
Assignee | ||
Comment 11•24 years ago
|
||
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
Comment 12•24 years ago
|
||
I am shamed, and consent to your silence. r=shaver again.
Assignee | ||
Updated•24 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Assignee | ||
Comment 13•24 years ago
|
||
Fix in, but give me a reason (future compatibility?) for throwing instead of
returning void?
/be
Comment 14•24 years ago
|
||
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.
Description
•