Skip to main content

Bug Tracker

Side navigation

#4428 closed bug (invalid)

Opened March 26, 2009 01:55PM UTC

Closed October 29, 2010 06:22AM UTC

Last modified October 29, 2010 06:44PM UTC

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:
Description

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 March 26, 2009 01:56PM UTC.

    example of this selector

  • testcase.html (0.4 KB) - added by petersendidit November 13, 2009 07:52PM UTC.

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

Change History (2)

Changed October 29, 2010 06:22AM UTC by addyosmani comment:1

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.

Changed October 29, 2010 06:44PM UTC by jitter comment:2

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