Bug Tracker

Opened 14 years ago

Closed 12 years ago

Last modified 12 years ago

#4428 closed bug (invalid)

SELECTOR doesn't work

Reported by: simonxy Owned by: john
Priority: critical Milestone: 1.4
Component: selector Version: 1.3.2
Keywords: Cc:
Blocked by: Blocking:


If I use the following selector:

$('~ span:first', this) doesn't work - it won't found any element. (this is input element, but it doesn't matter)

If I remove :first, than it works. $('~ span', this) - THIS WORKS.

In old library 1.2.1.js the first example works: $('~ span:first', this) - THIS WORKS IN PREVIOUS LIBRARY.

Attachments (2)

bamboo.zip (22.7 KB) - added by simonxy 14 years ago.
example of this selector
testcase.html (442 bytes) - added by petersendidit 13 years ago.
here is a simplified test case that shows the seelctor problem.

Download all attachments as: .zip

Change History (4)

Changed 14 years ago by simonxy

Attachment: bamboo.zip added

example of this selector

Changed 13 years ago by petersendidit

Attachment: testcase.html added

here is a simplified test case that shows the seelctor problem.

comment:1 Changed 12 years ago by addyosmani

Resolution: invalid
Status: newclosed

Your test case is using invalid HTML (for this particular problem) which is why your code is likely failing. If you wish to find a child element belong to a particular parent, you need to have that child actually be a child *of that parent* rather than outside of it. Not doing so would render your test case to not function correctly which is what is happening here.

comment:2 Changed 12 years ago by jitter

Why would his HTML be invalid? He doesn't want to find a child, he wants to find a sibling. ~ is the Next Siblings Selector.

In this case he wants to find all/first span sibling of every div.

I made a test case. If you switch between the various jQuery version you will notice that

jQuery 1.2.6 returned 1 for all tests

jQuery 1.3.2 returns 0 for Test 2 and Test 4

jQuery 1.4.3 fails to return 1 for all tests but Test 5.

This is a serious regression getting worse since jQuery 1.2.6

Note: See TracTickets for help on using tickets.