Bug Tracker

Modify

Ticket #8943 (closed bug: fixed)

Opened 3 years ago

Last modified 23 months ago

':text' is case-sensitive on type whereas '[type=text]' is case-insensitive

Reported by: david@… Owned by:
Priority: low Milestone: 1.next
Component: selector Version: 1.5.2
Keywords: needsreview Cc:
Blocking: Blocked by:

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;

Change History

comment:1 follow-up: ↓ 2 Changed 3 years ago by addyosmani

  • Keywords needsreview added
  • Priority changed from undecided to low
  • Component changed from unfiled to selector

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.

comment:2 in reply to: ↑ 1 Changed 3 years ago by timmywil

  • Status changed from new to open

I went ahead and added a PR on Sizzle if we want this.  pull request

comment:3 Changed 3 years ago by john

Confirmed in bug triage.

comment:4 Changed 23 months ago by timmywil

  • Status changed from open to closed
  • Resolution set to fixed

Update Sizzle: Case insensitive text filter. Fixes #8943

Changeset: e9e12219796deeff75f70f4be375609ae6eb3283

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.