Closed Bug 825009 Opened 9 years ago Closed 9 years ago

Handles NaN and Infinity passed to .valueAsNumber

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla20

People

(Reporter: mounir, Unassigned)

References

(Depends on 1 open bug)

Details

(Keywords: doc-bug-filed)

Attachments

(1 file)

Attached patch PatchSplinter Review
.valueAsNumber = NaN should set the value to ""
.valueAsNumber = +/-Infinity should throw a TypeError. For the moment we can't throw that so we are just throwing another error.
Attachment #696069 - Flags: review?(bugs)
Did you consider using NS_ENSURE_FINITE from nsContentUtils.h?
Comment on attachment 696069 [details] [diff] [review]
Patch

Since rest of the form element code uses MOZ_DOUBLE_* better to use it here too.
However, we need to make DOM code to use only one style of NAN macros.
A followup bug would be good.

// "" is being converted to 0.
s/being//

Add a todo for TypeError.
Attachment #696069 - Flags: review?(bugs) → review+
Depends on: 825197
(In reply to Olli Pettay [:smaug] from comment #3)
> Comment on attachment 696069 [details] [diff] [review]
> Patch
> 
> Since rest of the form element code uses MOZ_DOUBLE_* better to use it here
> too.
> However, we need to make DOM code to use only one style of NAN macros.
> A followup bug would be good.

bug 825200

> Add a todo for TypeError.

There is a todo but that wasn't pointing to a bug. There is now bug 825197.
https://hg.mozilla.org/mozilla-central/rev/0bb4773db082
Status: NEW → RESOLVED
Closed: 9 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla20
Keywords: dev-doc-needed
See bug 866440 for documentation.
You need to log in before you can comment on or make changes to this bug.