Side navigation
#10823 closed bug (duplicate)
Opened November 18, 2011 03:13AM UTC
Closed November 18, 2011 03:21PM UTC
Last modified November 18, 2011 03:21PM UTC
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.
Attachments (0)
Change History (4)
Changed November 18, 2011 03:53AM UTC by comment:1
owner: | → AlistairB |
---|---|
status: | new → pending |
Changed November 18, 2011 03:58AM UTC by comment:2
owner: | AlistairB |
---|---|
status: | pending → 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.
Changed November 18, 2011 03:21PM UTC by comment:3
resolution: | → duplicate |
---|---|
status: | new → closed |
Can you reduce that to _just_ illustrate the bug?