Closed Bug 636737 Opened 14 years ago Closed 12 years ago

Implement valueAsNumber for <input type='number'>

Categories

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

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla16

People

(Reporter: mounir, Assigned: mounir)

References

(Blocks 1 open bug)

Details

(Keywords: doc-bug-filed, html5)

Attachments

(1 file, 1 obsolete file)

Actually, we don't want that. Olli and I tried to have it removed from the specs but I wrote a patch a long time ago so I'm going to refresh it and attach it here. Bug against the specs: http://www.w3.org/Bugs/Public/show_bug.cgi?id=11887
Attached patch Patch v1 (obsolete) (deleted) — Splinter Review
I'm asking a review but this might be canceled and the bug marked as WONTFIX if the specs remove this attribute.
Assignee: nobody → mounir.lamouri
Status: NEW → ASSIGNED
Attachment #515087 - Flags: review?(jonas)
Whiteboard: [needs review]
Attached patch Patch v1.1 (deleted) — Splinter Review
Use double instead of float.
Attachment #515087 - Attachment is obsolete: true
Attachment #515087 - Flags: review?(jonas)
Attachment #515641 - Flags: review?(jonas)
Depends on: 636750
I'd still like to see either a reasoning for valueAsNumber or it to be removed from HTML.
Blocks: 639661
Comment on attachment 515641 [details] [diff] [review] Patch v1.1 >+nsHTMLInputElement::GetValueAsNumber(double* aValueAsNumber) >+{ >+ if (!DoesValueAsNumberApply()) { >+ *aValueAsNumber = std::numeric_limits<double>::quiet_NaN(); >+ return NS_ERROR_DOM_INVALID_STATE_ERR; >+ } XPCOM rules actually dictate that you should not assign to the out parameter here. r=me with that fixed
Attachment #515641 - Flags: review?(jonas) → review+
(In reply to comment #4) > Comment on attachment 515641 [details] [diff] [review] > Patch v1.1 > > >+nsHTMLInputElement::GetValueAsNumber(double* aValueAsNumber) > >+{ > >+ if (!DoesValueAsNumberApply()) { > >+ *aValueAsNumber = std::numeric_limits<double>::quiet_NaN(); > >+ return NS_ERROR_DOM_INVALID_STATE_ERR; > >+ } > > XPCOM rules actually dictate that you should not assign to the out parameter > here. > > r=me with that fixed Eh, this was actually, wrong: I shouldn't throw an exception when getting a value while valueAsNumber doesn't apply but just returning NaN. This is fixed locally.
Whiteboard: [needs review] → [ready to land][waits for dependencies]
Whiteboard: [ready to land][waits for dependencies] → [ready to land][waits for dependencies][wait for specs decision]
Spec bug has been closed as RESOLVED WONTFIX, so I guess patch should be landed into m-c.
(In reply to Atul Aggarwal from comment #6) > Spec bug has been closed as RESOLVED WONTFIX, so I guess patch should be > landed into m-c. This will land with the entire <input type='number'> patch queue which is not ready yet.
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Whiteboard: [ready to land][waits for dependencies][wait for specs decision]
Target Milestone: --- → mozilla16
This patch landed too early, as Firefox 16 has no input type=number, but this numberAsValue! Without number support, the result is always NaN, which breaks feature detection. if (input.valueAsNumber !== undefined){ ... input.valueAsNumber; }else{ ... parseInt(input.value, 10); }
Just for the record. The feature detection had to be changed to: if (input.type === "number" && input.valueAsNumber !== undefined) the problem is imo still valid.
See bug 866457 for documentation.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: