#4798 closed bug (worksforme)
Selecting descendants of something:last yields duplicates
Reported by: | Catrope | Owned by: | john |
---|---|---|---|
Priority: | major | Milestone: | 1.4 |
Component: | selector | Version: | 1.3.2 |
Keywords: | :last descendants | Cc: | |
Blocked by: | Blocking: |
Description
I have a document with two <table> with class="toc", each containing a nested <ul> with a bunch of <li>s. $('.toc * li') will return all <li> elements as expected. $('.toc:last * li') returns all <li> elements in the last table, as expected, but returns each <li> four times. This means, among other things, that $('.toc:last * li').each(someFunction); calls someFunction() four times for every <li>. Example attached.
Attachments (1)
Change History (4)
Changed 14 years ago by
comment:1 Changed 14 years ago by
Component: | unfilled → selector |
---|---|
Owner: | set to john |
comment:2 follow-up: 3 Changed 13 years ago by
Keywords: | :last descendants added |
---|---|
Resolution: | → worksforme |
Status: | new → closed |
I have recreated your test case here Live Test Case, however using jQuery 1.4.3 this appears to be working fine now.
comment:3 Changed 13 years ago by
Replying to addyosmani:
however using jQuery 1.4.3 this appears to be working fine now.
What do you mean by that? Your test case shows the exact behavior Catrope reported. Using Opera 10.62 I get 12 alerts when opening your test saying "One/Two/Three-B" 4 times. Instead of only getting 3 alerts (one for each li).
Another test case. For every jQuery version > 1.2.6 the result of $('.toc * li').length
is different from $('.toc:last * li').length
although there is only one .toc
element in my test case and thus the results should be the same.
$('.toc * li').length
correctly returns the same as $('.toc li').length
(3 for my test)
But $('.toc:last * li').length
returns the #non-li-descendants of .toc
X #of li-descendants of toc
(12 instead of 3).,
This seems to happen no matter what PSEUDO selector your use in the selector
Test case