Side navigation
#9424 closed bug (duplicate)
Opened May 25, 2011 06:56PM UTC
Closed May 27, 2011 12:11AM UTC
Last modified May 27, 2011 12:11AM UTC
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.
Attachments (0)
Change History (4)
Changed May 25, 2011 06:59PM UTC by comment:1
component: | unfiled → selector |
---|---|
owner: | → nonsensery |
status: | new → pending |
Changed May 26, 2011 05:06PM UTC by comment:2
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
Changed May 27, 2011 12:11AM UTC by comment:3
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!