#8163 closed bug (duplicate)
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: | #8039 | Blocking: |
Description
Given this HTML:
<input> <!-- W3C standards default is text --> <br> <input type="text"> <!-- explicit text -->
This selector:
$('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:
$(':input[type="text"]')
Tested in Chrome 9 beta on Mac, and Firefox 3.6 on Mac.
Test Case: http://jsfiddle.net/eMENG/1/
Change History (6)
comment:1 Changed 12 years ago by
comment:3 Changed 12 years ago by
Blocked by: | 8039 added |
---|---|
Component: | unfiled → selector |
Milestone: | 1.next → 1.5.1 |
Priority: | undecided → high |
Status: | new → open |
comment:4 Changed 12 years ago by
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
comment:5 Changed 12 years ago by
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.