Side navigation
#8943 closed bug (fixed)
Opened April 22, 2011 07:27AM UTC
Closed May 29, 2012 12:11AM UTC
':text' is case-sensitive on type whereas '[type=text]' is case-insensitive
Reported by: | david@cusimano.com | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | 1.next |
Component: | selector | Version: | 1.5.2 |
Keywords: | needsreview | Cc: | |
Blocked by: | Blocking: |
Description
Documentation for :text selector says $(':text') is equivalent to $('[type=text]') however I have verified that it is not.
Assume want to match <input type="TEXT"> -- N.B.: uppercase TEXT.
'input:text' is case sensitive on type and thus does not match.
'input[type=text]' is case insensitive and thus does match.
The bug is that the :text filter calls elem.getAttribute( "type" ) which returns "TEXT" in this case, whereas elem.type returns "text" in this case.
In the definition of the :text filter function, replace:
var attr = elem.getAttribute( "type" ), type = elem.type;
with:
var attr = elem.getAttribute( "type" ).toLowerCase(), type = elem.type;
Attachments (0)
Change History (4)
Changed April 22, 2011 11:03AM UTC by comment:1
component: | unfiled → selector |
---|---|
keywords: | → needsreview |
priority: | undecided → low |
Changed April 22, 2011 02:45PM UTC by comment:2
status: | new → open |
---|
I went ahead and added a PR on Sizzle if we want this.
Changed July 12, 2011 06:05PM UTC by comment:3
Confirmed in bug triage.
There is currently a note in the docs for :text that clearly states:
''Note: As of jQuery 1.5.2, :text selects input elements that have no specified type attribute (in which case type="text" is implied).'' (note here the case of 'text')
Baring this in mind, I think we'll have to leave this ticket open for a discussion regarding whether or not a change here is warranted or simply a change in the wording of the docs to reflect the exact behaviour.