Closed
Bug 636737
Opened 14 years ago
Closed 12 years ago
Implement valueAsNumber for <input type='number'>
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
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)
(deleted),
patch
|
sicking
:
review+
|
Details | Diff | Splinter Review |
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
Assignee | ||
Updated•14 years ago
|
Assignee | ||
Comment 1•14 years ago
|
||
I'm asking a review but this might be canceled and the bug marked as WONTFIX if the specs remove this attribute.
Assignee | ||
Updated•14 years ago
|
Whiteboard: [needs review]
Assignee | ||
Comment 2•14 years ago
|
||
Use double instead of float.
Attachment #515087 -
Attachment is obsolete: true
Attachment #515087 -
Flags: review?(jonas)
Attachment #515641 -
Flags: review?(jonas)
Comment 3•14 years ago
|
||
I'd still like to see either a reasoning for valueAsNumber or it to be
removed from HTML.
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+
Assignee | ||
Comment 5•14 years ago
|
||
(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]
Assignee | ||
Updated•14 years ago
|
Whiteboard: [ready to land][waits for dependencies] → [ready to land][waits for dependencies][wait for specs decision]
Comment 6•13 years ago
|
||
Spec bug has been closed as RESOLVED WONTFIX, so I guess patch should be landed into m-c.
Assignee | ||
Comment 7•13 years ago
|
||
(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.
Assignee | ||
Comment 8•12 years ago
|
||
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
Comment 9•12 years ago
|
||
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);
}
Comment 10•12 years ago
|
||
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.
You need to log in
before you can comment on or make changes to this bug.
Description
•