Bug Tracker

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#10823 closed bug (duplicate)

inconsistent results when using [value=blah]

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

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 (4)

comment:1 Changed 8 years ago by Rick Waldron

Owner: set to AlistairB
Status: newpending

Can you reduce that to _just_ illustrate the bug?

comment:2 Changed 8 years ago by dmethvin

Owner: AlistairB deleted
Status: pendingnew

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 8 years ago by timmywil

Resolution: duplicate
Status: newclosed

comment:4 Changed 8 years ago by timmywil

Duplicate of #9830.

Note: See TracTickets for help on using tickets.