Bug Tracker

Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#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 Changed 9 years ago by addyosmani

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.

comment:2 Changed 9 years ago by addyosmani

Duplicate of #8163.

comment:3 in reply to:  1 Changed 9 years ago by patrickwhalen

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 will want to support this input type at some point.

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

Version 2, edited 9 years ago by patrickwhalen (previous) (next) (diff)

comment:4 Changed 9 years ago by jitter

Resolution: duplicate
Status: closedreopened

comment:5 Changed 9 years ago by jitter

Component: unfiledmisc
Priority: undecidedhigh
Resolution: duplicate
Status: reopenedclosed

comment:6 Changed 9 years ago by jitter

Duplicate of #8039.

comment:7 Changed 9 years ago by dmethvin

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 9 years ago by gnarf

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

Note: See TracTickets for help on using tickets.