Bug Tracker

Modify

Ticket #6443 (closed bug: wontfix)

Opened 3 years ago

Last modified 14 months ago

Some multi stage sibling selectors delivering different results in jQuery 1.4 vs 1.3

Reported by: rsinton Owned by:
Priority: high Milestone: 1.next
Component: selector Version: 1.4.4
Keywords: sibling selector contains Cc:
Blocking: Blocked by:

Description

Some selectors, such as

$( '#one ~ #two span:contains(word)' )

and

$( '#one + #two span:visible' )

are giving me the results I expect in 1.3, but not in 1.4

Reduced case attached, with similar selectors that work as expected for comparison, e.g.

$( '#one ~ #two span:last' )

is fine.

Seems to only be for (pardon my invented terminology) some qualifed ancestors following sibling selection ( ~ or + ).

Verified in Safari 4.0.4 and Firefox 3.5.9. Tried with jQuery 1.4.2 and nightly build 1.4.3pre 28 Feb 2010.

Attachments

test.html Download (2.0 KB) - added by rsinton 3 years ago.
test2.html Download (2.3 KB) - added by rsinton 3 years ago.

Change History

Changed 3 years ago by rsinton

comment:1 Changed 3 years ago by rsinton

That should of course read "qualified *descendants* of selected siblings".

comment:2 Changed 3 years ago by rsinton

Some code scrounging, head-scratching, and testing points to the shortcut at line 2694 (1.4.2) with the heading: "Take a shortcut and set the context if the root selector is an ID". Disabling this removes the problem.

Extra test cases G2 and G3 in test2.html also show that the problem goes away if the root selector is a class selector rather than ID selector.

Changed 3 years ago by rsinton

comment:3 Changed 3 years ago by rsinton

Actually, the more I look at it, the more I think the fix is just to disqualify sibling selectors for that shortcut (middle line added):

if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML && !parts[1] === "~" && !parts[1] === "+" && Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {

The reason being that the LHS of 'a b' or 'a > b' is the same thing as a context for the RHS, but that's not true for 'a ~ b' or 'a + b'

comment:4 Changed 3 years ago by snover

  • Milestone 1.4.3 deleted

Resetting milestone to future.

comment:5 Changed 2 years ago by snover

  • Priority set to high
  • Status changed from new to open
  • Version changed from 1.4.2 to 1.4.4
  • Milestone set to 1.4.5

comment:6 Changed 2 years ago by ctlajoie

I added  another test case to snover's set linked above.
It involves a regression that started with 1.4.3 involving sibling selectors passed to the find function.
For example: $('#one').find('~ #two')
It works for jQuery 1.3.2 and 1.4.2, but fails in 1.4.3 and 1.4.4.

I considered adding a new ticket for this but decided to just comment here. If it seems different enough to you guys you can make a new ticket.

comment:7 Changed 23 months ago by john

  • Status changed from open to closed
  • Resolution set to wontfix

Unfortunately this isn't something that we're going to be able to fix in the current incarnation of the Sizzle engine. We hope to fix this in the near future.  http://docs.jquery.com/Won%27t_Fix

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.