#8164 closed bug (duplicate)
Inconsistent results when selecting "number" type inputs
Reported by: | patrickwhalen | Owned by: | |
---|---|---|---|
Priority: | high | Milestone: | 1.next |
Component: | misc | Version: | 1.5 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
I don't know if this is intended to be supported, but "number" inputs are sometimes not selected when using [type="number"]
.
Given this HTML:
<input type="number"> <!-- number input -->
This selector selects the input:
$('input[type="number"]')
But this one (using the :input
pseudo selector) does not:
$(':input[type="number"]')
Verified in Firefox 3.6 on Mac.
Works in Chrome 9 beta on Mac, but received reports that Chrome 8 experienced the same problem.
Test Case: http://jsfiddle.net/eMENG/2/
Change History (8)
comment:1 follow-up: 3 Changed 13 years ago by
Resolution: | → duplicate |
---|---|
Status: | new → closed |
comment:3 Changed 13 years ago by
Replying to addyosmani:
...please note that (to the best of my knowledge) there are no valid types based on numbers for this particular case eg. <input type=5>. I would argue that <input type="5"> should also be invalid...
I'm not referring to a numeric value. I'm referring to the HTML5 "number" type element, which provides increment/decrement buttons. I assume jQuery/Sizzle will want to support this input type at some point.
comment:4 Changed 13 years ago by
Resolution: | duplicate |
---|---|
Status: | closed → reopened |
comment:5 Changed 13 years ago by
Component: | unfiled → misc |
---|---|
Priority: | undecided → high |
Resolution: | → duplicate |
Status: | reopened → closed |
comment:7 Changed 13 years ago by
Same root cause as #8663 and #8039, a combination of HTML5 and Sizzle incompatibilities. input[type="number"]
is a valid standard CSS selector and goes through the browser's querySelectorAll implementation. :input[type="number"]
is a jQuery selector extension so it goes through Sizzle's Javascript selector engine. In Sizzle we look at the type property, not the type attribute, and the property is "text" for unrecognized attributes like "number".
comment:8 Changed 13 years ago by
More accurately, this bug is a dupe of #8039 -- the fix already exists there to bring the Sizzle implementation closer to that of the qSA for the type
attribute... The browser normalizes the type
property to 'text'
for any unsupported input types, which is why Sizzles implementation currently fails to produce the same results as the qSA
Closing as a duplicate of your other ticket (#8163). Even if there's a difference between text and numeric input, because you're using them in the context of a string in your query where both this ticket and the other are essentially attempting to do the same thing, we're going to end up having similar resolutions on them. Also, please note that (to the best of my knowledge) there are no valid types based on numbers for this particular case eg. <input type=5>. I would argue that <input type="5"> should also be invalid, but we'll discuss how jQuery will handle these cases on 8163.