Bugzilla – Bug 20496
valueAsNumber's setter should be "double", not "unrestricted double". Or the prose needs to handle NaN/Infinity.
Last modified: 2013-02-13 20:21:27 UTC
valueAsNumber's setter should be "double", not "unrestricted double". Or the
prose needs to handle NaN/Infinity.
Posted from: 22.214.171.124
User agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.101 Safari/537.11
heycam: Here's another example of wanting a different setter type than getter type. I want to return NaN sometimes (unrestricted double), but the setter needs to just be double.
Actually for NaN volkmar suggests that setting the value to "" might be more useful. (This is what Gecko does.) Still need to throw for Infinity, though.
Gecko/Firefox 20 implements the following behaviour:
- |.valueAsNumber = NaN;| will set the value to the empty string (ie. equivalent to |.value = "";|.
- |.valueAsNumber = Infinity;| (or -Infinity) will throw without changing the value. Not that for the moment, Gecko doesn't throw TypeError for internal reasons. This will happen later.
This change should be soon (max 24 hours) available in a Nightly build. To test it on a Desktop version of Firefox, you have to enable the following pref in about:config: "dom.experimental_forms". The pref is enabled by default on Firefox Mobile.
More information about the change:
Checked in as WHATWG revision r7723.
Check-in comment: Define setting valueAsNumber to Infinity or NaN.