#9424 closed bug (duplicate)
filter('[href]') fails to match links with empty href attrs in some cases
Reported by: | nonsensery | Owned by: | nonsensery |
---|---|---|---|
Priority: | high | Milestone: | 1.next |
Component: | selector | Version: | 1.6 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
(This is similar to #4873, but not the same. In this case, the selector correctly matches these elements in some cases, but not in others)
Environment: This bug occurs in jQuery 1.2 - 1.6, but the failures are different in 1.2 and 1.3. I would guess that it also affects jQuery 1.6.1, but that version is unavailable for testing. Verified in Mac Chrome 11, Firefox 4, Safari 5; IE 9.
Please see this test case: http://jsfiddle.net/Zh7ME/2/
In jQuery 1.4 - 1.6, when using the filter()
method, the selector [href]
fails to match a link with an href
attribute with an empty value, e.g. <a href="">example link</a>
, but only if there are other elements in the set. If there is a single element, filter()
works correctly. Also, it appears that the selector works correctly when passed to the jQuery function itself, like: $('a[href]')
.
In earlier versions of jQuery (1.2 - 1.3), and in older versions of IE (7 - 8) there are different failures. You can change the jQuery version in the test case to see those failures, but (personally) I am not concerned with these environments.
To summarize, the problem is not that the selector does not work, but rather that it behaves differently under different circumstances.
Change History (4)
comment:1 Changed 11 years ago by
Component: | unfiled → selector |
---|---|
Owner: | set to nonsensery |
Status: | new → pending |
comment:2 Changed 11 years ago by
Status: | pending → new |
---|
The test case above is fairly complicated because the characteristics of this bug are complex, but here is a more simple example that illustrates one aspect of it: http://jsfiddle.net/2KH7c/
Hope that helps,
Alex
comment:3 Changed 11 years ago by
Priority: | undecided → high |
---|---|
Resolution: | → duplicate |
Status: | new → closed |
Could you possibly reduce that test case? Instead of outputting html results, try using console.log() :D
Thanks!