]> source.dussan.org Git - jquery.git/commitdiff
Fix #13846: .prev sort direction
authorRichard Gibson <richard.gibson@gmail.com>
Wed, 1 May 2013 15:33:06 +0000 (11:33 -0400)
committerRichard Gibson <richard.gibson@gmail.com>
Wed, 1 May 2013 15:33:06 +0000 (11:33 -0400)
src/traversing.js
test/unit/traversing.js

index 6f68e782123cd09bfa0c32e4b3debbd5e01a254e..b5a38f3635a0bf8b62c91767174cdf38b5e45ece 100644 (file)
@@ -1,4 +1,5 @@
 var isSimple = /^.[^:#\[\.,]*$/,
+       rparentsprev = /^(?:parents|prev(?:Until|All))/,
        rneedsContext = jQuery.expr.match.needsContext,
        // methods guaranteed to produce a unique set when starting from a unique set
        guaranteedUnique = {
@@ -200,8 +201,8 @@ jQuery.each({
                                jQuery.unique( matched );
                        }
 
-                       // Reverse order for parents* and prev*
-                       if ( name[ 0 ] === "p" && name !== "parent" ) {
+                       // Reverse order for parents* and prev-derivatives
+                       if ( rparentsprev.test( name ) ) {
                                matched.reverse();
                        }
                }
index b35a5c3cce4b83368c82c97aa29140c58dc4d89c..89ed81ac6000ef190ff36aebe01677055d6cceb4 100644 (file)
@@ -682,7 +682,7 @@ test("sort direction", function() {
                        parents: true,
                        parentsUntil: true,
                        next: false,
-                       prev: true,
+                       prev: false,
                        nextAll: false,
                        prevAll: true,
                        nextUntil: false,