Bug Tracker

Modify

Ticket #10823 (closed bug: duplicate)

Opened 18 months ago

Last modified 18 months ago

inconsistent results when using [value=blah]

Reported by: AlistairB Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: git
Keywords: Cc:
Blocking: Blocked by:

Description

There are some inconsistencies when using [value=blah] in selectors (jQuery all versions apparently up to 1.7.1rc1) which works the same across all browsers I have tested.

 http://jsfiddle.net/AlistairB/H8bgv/3/

This highlights all the issues I have found. It is written with the expectation that value will match or not match depending what has actually been entered into the textbox (not sure if it is actually supposed to work like this).

Specifically concerning points are:

  1. :text[value=blah] vs input[value=blah]
  2. textboxes that start with an empty attr of value vs textboxes that start with no value attr.

Change History

comment:1 Changed 18 months ago by rwaldron

  • Owner set to AlistairB
  • Status changed from new to pending

Can you reduce that to _just_ illustrate the bug?

comment:2 Changed 18 months ago by dmethvin

  • Owner AlistairB deleted
  • Status changed from pending to new

The W3C standard selectors like input[type=text] are returning correct results, the ones like :text are not. The W3C says the selector should match against the value attribute on the element, not the current dynamic value property set by the program or typed by by a user.

The crazy thing with the standard is that they *do* take some dynamic state into account such as the :checked selector. Since the browser's querySelectorAll method obeys the standard, it's not like jQuery can easily change the rules there. To implement the jQuery ones like :text, which existed before querySelectorAll, we use Sizzle's Javascript engine and look at the value property rather than the value attribute. I think that may change in the future though.

As the docs on :text and the other jQuery custom selectors spell out, they are non-standard and should be avoided because, well, you can tell they're not consistent with the standard selectors and they also cause the selector engine to take a slower path through the code.

 http://www.w3.org/TR/selectors/

comment:3 Changed 18 months ago by timmywil

  • Status changed from new to closed
  • Resolution set to duplicate

comment:4 Changed 18 months ago by timmywil

Duplicate of #9830.

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.