Bug Tracker

Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#395 closed bug (duplicate)

$(E ~ F) fails if E is the first sibling

Reported by: anonymous Owned by:
Priority: major Milestone:
Component: core Version:
Keywords: Cc:
Blocked by: Blocking:


I am having a problem with the "element preceded by" syntax for $. Example:

$(document).ready(function() {
  $("div ~ span").background("red");

<body> <div> this is a div </div>
<span> this is a span </span> </body>

This does not turn the <span> to red. If I use "+" instead of "~", then the <span> turns red. The relevant code (lines 1653-1655 in jquery.js, rev 557), says:

  if ( s.n > 0 )
    for ( var i = s.n; i < s.length; i++ )
      r.push( s[i] );

I haven't tested this, but I would eliminate the s.n > 0 check and I would start the iteration at s.n+1:

  for ( var i = s.n+1; i < s.length; i++ )
    r.push( s[i] );

Change History (1)

comment:1 Changed 16 years ago by brandon

Resolution: duplicate
Status: newclosed

See #310

This is now fixed in SVN Rev: 585

Note: See TracTickets for help on using tickets.