jQuery Attribute Selector Bug
|Reported by:||Owned by:|
At the above jsFiddle example, we have extremely simple markup:
<input tabindex="0" name="Username" /> <input tabindex="1" name="Password" /> <input type="hidden" name="Hidden" value="value" /> <input tabindex="2" type="submit" value="Submit" /> <a href="#" id="ForgotPassword">Forgot Password?</a>
...I get confusing results. The first selector does as I intended (i.e., select the single html element on the page that has an attribute of
tabindex with a literal value of
0, which is the
Username input text field). I would then expect the second selector to produce the same result, as it has the same selector but with one extra restriction that the element be visible. However, I actually get more results than the first, despite the more restrictive selector (i.e., it matches
Username text field but also matches the
ForgotPassword anchor link as well).
It appears what happens is that when the
:visible selector is added, the attribute selector is not doing a literal match anymore. When I do the same attribute selector, but without quotes...
...I now get all elements which effectively have a tab index of zero by default, not just the one that literally has the attribute in its markup (i.e., now we match the
Username text field and the
ForgotPassword link, and additionally the hidden input field in the case of the selector without the visibility check).
What I'm gathering is that when the
:visible selector is appended to the attribute selector of
[tabindex="0"], it switches to behaving like the
[tabindex=0] attribute selector instead.