Side navigation
#8163 closed bug (duplicate)
Opened February 03, 2011 03:55PM UTC
Closed February 28, 2011 06:44PM UTC
Last modified February 28, 2011 06:44PM UTC
Selecting "text" inputs that don't have the "text" attribute explicitly set gives mixed results
Reported by: | patrickwhalen | Owned by: | |
---|---|---|---|
Priority: | high | Milestone: | 1.5.1 |
Component: | selector | Version: | 1.5 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Given this HTML:
#!xml <input> <!-- W3C standards default is text --> <br> <input type="text"> <!-- explicit text -->
This selector:
#!js $('input[type="text"]')
...does not select the <input>
that does not have its "text" attribute set explicitly.
But this selector (with the :input
pseudo selector) does select it:
#!js $(':input[type="text"]')
Tested in Chrome 9 beta on Mac, and Firefox 3.6 on Mac.
**Test Case:** http://jsfiddle.net/eMENG/1/
Attachments (0)
Change History (6)
Changed February 03, 2011 04:15PM UTC by comment:1
Changed February 03, 2011 06:16PM UTC by comment:3
blockedby: | → 8039 |
---|---|
component: | unfiled → selector |
milestone: | 1.next → 1.5.1 |
priority: | undecided → high |
status: | new → open |
Changed February 17, 2011 11:15AM UTC by comment:4
the fix for #8039 would make even
$(':input[type=text]')fail... Considering that this bug is actually a failure on the qSA implementation, I'd argue that you should always have
type='text'on your inputs... Looking for inputs without a type?? after my fix for #8039 is applied
$('input:not([type])')would find inputs without a type attribute defined in the HTML
Changed February 28, 2011 06:44PM UTC by comment:5
resolution: | → duplicate |
---|---|
status: | open → closed |
For the W3C standard querySelectorAll method, a selector of "input[type=text]" requires that there be an actual attribute with a type of "text" for a match. The reason that ":input" works is that it is a jQuery selector extension, and so uses the Sizzle Javascript engine rather than querySelectorAll. That extension looks at the element's type *property* which is text by default (and also if the type attribute contains an unrecognized type).
Not sure of the resolution on jQuery's end, but it is bad practice to not specify a type because it will prevent querySelectorAll from working.