is this a bug?

is this a bug?

EDIT: Pretty sure it is, or behaviour changes from 1.7.0 onward.  Reporting.

I've been trying to isolate a second possible bug (or intentional behaviour change) where there is an inconsistency between 1.7.2 and 1.8.0, but I can't seem to reproduce it in a minimalised code.

But during the process of trying to recreate it I noticed that the following html:

  1. <html>
  2. <head>
  3. <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
  4. </head>
  5. <body>
  6. <script type="text/javascript">
  7.   $('<div class="ch"><div class="chh">chapter 1</div></div>').appendTo("body");
  8.  
  9.   var a;
  10.   $('<div class="ch"><div class="chh">chapter 2</div></div>').appendTo("body");
  11.   a = $("body > .ch:last");
  12.  
  13.   console.log(
  14.     a.prevAll().length);
  15.   console.log(
  16.     a.prevAll(".ch").length);
  17.   console.log(
  18.     a.prevAll(".ch:first").length);
  19.   console.log(
  20.     a.prevAll(".ch:first div:first").length);
  21.   console.log(
  22.     a.prevAll(".ch:first .chh").length);
  23. </script>
  24. </body>
  25. </html>

produces the following output (in any jquery version):


2
1
1
1
0

Shouldn't those last two outputs be the same?