Skip to main content

Bug Tracker

Side navigation

#395 closed bug (duplicate)

Opened November 15, 2006 04:24AM UTC

Closed November 15, 2006 03:54PM UTC

Last modified June 19, 2007 07:46AM UTC

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

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] );
Attachments (0)
Change History (1)

Changed November 15, 2006 03:54PM UTC by brandon comment:1

resolution: → duplicate
status: newclosed

See #310

This is now fixed in SVN Rev: 585