Bug 20496 - valueAsNumber's setter should be "double", not "unrestricted double". Or the prose needs to handle NaN/Infinity.
valueAsNumber's setter should be "double", not "unrestricted double". Or the ...
Product: WHATWG
Classification: Unclassified
Component: HTML
Other other
: P3 normal
: Unsorted
Assigned To: Ian 'Hixie' Hickson
Depends on:
  Show dependency treegraph
Reported: 2012-12-22 17:34 UTC by contributor
Modified: 2013-02-13 20:21 UTC (History)
4 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description contributor 2012-12-22 17:34:33 UTC
Specification: http://www.whatwg.org/specs/web-apps/current-work/
Multipage: http://www.whatwg.org/C#dom-input-valueasnumber
Complete: http://www.whatwg.org/c#dom-input-valueasnumber

valueAsNumber's setter should be "double", not "unrestricted double". Or the
prose needs to handle NaN/Infinity.

Posted from:
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
Comment 1 Ian 'Hixie' Hickson 2012-12-22 17:35:58 UTC
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.
Comment 2 Ian 'Hixie' Hickson 2012-12-22 17:38:13 UTC
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.
Comment 3 Mounir Lamouri 2012-12-28 13:06:19 UTC
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:
Comment 4 contributor 2013-02-13 20:21:27 UTC
Checked in as WHATWG revision r7723.
Check-in comment: Define setting valueAsNumber to Infinity or NaN.