Skip to main content

Bug Tracker

Side navigation

#8164 closed bug (duplicate)

Opened February 03, 2011 04:12PM UTC

Closed February 03, 2011 06:10PM UTC

Last modified March 13, 2012 04:00PM UTC

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:

#!xml
<input type="number">  <!-- number input -->

This selector selects the input:

#!js
$('input[type="number"]')

But this one (using the :input pseudo selector) does not:

#!js
$(':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/

Attachments (0)
Change History (8)

Changed February 03, 2011 04:46PM UTC by addyosmani comment:1

resolution: → duplicate
status: newclosed

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.

Changed February 03, 2011 04:46PM UTC by addyosmani comment:2

Duplicate of #8163.

Changed February 03, 2011 06:00PM UTC by patrickwhalen comment:3

_comment0: Replying to [comment:1 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 will want to support this input type at some point. \ \ http://www.w3.org/html/wiki/Elements/input/number1296756363426934
_comment1: Replying to [comment:1 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 will want to support this input type at some point. \ \ http://www.w3.org/html/wiki/Elements/input/number \ \ **EDIT: Forget that last sentence above the link. Where "number" types are supported, qsa will also be supported.**1296756403755132
_comment2: Replying to [comment:1 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 will want to support this input type at some point. \ \ http://www.w3.org/html/wiki/Elements/input/number \ 1296756450180528

Replying to [comment:1 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.

http://www.w3.org/html/wiki/Elements/input/number

Changed February 03, 2011 06:10PM UTC by jitter comment:4

resolution: duplicate
status: closedreopened

Changed February 03, 2011 06:10PM UTC by jitter comment:5

component: unfiledmisc
priority: undecidedhigh
resolution: → duplicate
status: reopenedclosed

Changed February 03, 2011 06:10PM UTC by jitter comment:6

Duplicate of #8039.

Changed February 03, 2011 07:19PM UTC by dmethvin comment:7

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".

Changed February 17, 2011 11:38AM UTC by gnarf comment:8

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