Closed
Bug 902126
Opened 11 years ago
Closed 11 years ago
watch() on HTMLSelectElement triggers an error on FF 23
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 903332
People
(Reporter: hugorteg, Unassigned)
Details
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:23.0) Gecko/20100101 Firefox/23.0 (Beta/Release)
Build ID: 20130730113002
Steps to reproduce:
Get the reference of a <select> element and use the watch() method:
<script>
var mySelect = document.getElementById('myselect');
mySelect.watch('disabled', function(attribute, oldval, newval){ return newval; });
</script>
Actual results:
On FF <=22 works as expected, but with FF 23, raises an error:
"can't watch non-native objects of class Proxy"
With no external JavaScript libraries.
Expected results:
The watch() method should work as on previous versions of FF
Reporter | ||
Updated•11 years ago
|
Summary: watch on HMTLSelectElement trigger error on FF 23 → watch() on HMTLSelectElement triggers an error on FF 23
Comment 1•11 years ago
|
||
Yep. That's because a <select> is in fact a proxy...
Note that afaik trying to watch() the value of the "disabled" property never worked anyway, since it's an accessor property with a side-channel that can change it.
Reporter | ||
Comment 2•11 years ago
|
||
Thanks for the clarification.
So, there is not a problem, just an error not triggered before FF 23.
Comment 3•11 years ago
|
||
Before FF23 <select> wasn't a proxy, but could have properties magically appear (but incorrectly not disappear) on it.
Comment 4•11 years ago
|
||
(In reply to Boris Zbarsky (:bz) (vacation Aug 10-19) from comment #1)
> Yep. That's because a <select> is in fact a proxy...
So what should we do? Can we now capture changes of select’s value property?
Comment 5•11 years ago
|
||
You couldn't before, and you can't now...
If all you care about is when someone does "select.value = whatever;", then you can capture that by interposing your own setter that calls through to the canonical setter. But if the user actually selects a different option, the .value will change with no notifications to the JS engine.
Comment 6•11 years ago
|
||
Not a JS engine bug, at least -- more an incidental effect of a DOM change.
I'd also note in passing that watchpoints installed/uninstalled by watch/unwatch have a bunch of bad effects in terms of performance and other metrics. (Not to mention their conceptually not working in some cases, like here before the FF23 change.) You really shouldn't use them if you can help it.
Status: UNCONFIRMED → RESOLVED
Closed: 11 years ago
Resolution: --- → INVALID
Summary: watch() on HMTLSelectElement triggers an error on FF 23 → watch() on HTMLSelectElement triggers an error on FF 23
Comment 7•11 years ago
|
||
(In reply to Boris Zbarsky (:bz) (vacation Aug 10-19) from comment #5)
> You couldn't before, and you can't now...
Why? watch("value" …) DID work on HTMLSelectElement perfectly.
> If all you care about is when someone does "select.value = whatever;", then
> you can capture that by interposing your own setter that calls through to
> the canonical setter.
It is not so easy however… Have you meant I should get canonical setter by Object.getOwnPropertyDescriptor(Object.getPrototypeOf(combo), "value") and use it in Object.defineProperty(combo, "value", {…})?
Comment 8•11 years ago
|
||
> Why? watch("value" …) DID work on HTMLSelectElement perfectly.
The call worked fine. The value would just change without your function being called.
> have you meant I should get canonical setter by
> Object.getOwnPropertyDescriptor(Object.getPrototypeOf(combo), "value")
Yes, exactly.
Comment 9•11 years ago
|
||
Here is link for my solution. It seems to work properly…
http://torbasow.livejournal.com/534771.html
Updated•11 years ago
|
Resolution: INVALID → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•