#6443 closed bug (wontfix)
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: | |
Blocked by: | Blocking: |
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 (2)
Change History (9)
Changed 13 years ago by
comment:1 Changed 13 years ago by
comment:2 Changed 13 years ago by
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 13 years ago by
Attachment: | test2.html added |
---|
comment:3 Changed 13 years ago by
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:5 Changed 12 years ago by
Milestone: | → 1.4.5 |
---|---|
Priority: | → high |
Status: | new → open |
Version: | 1.4.2 → 1.4.4 |
comment:6 Changed 12 years ago by
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 12 years ago by
Resolution: | → wontfix |
---|---|
Status: | open → closed |
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
That should of course read "qualified *descendants* of selected siblings".