aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Gibson <richard.gibson@gmail.com>2013-04-24 11:38:23 -0400
committerRichard Gibson <richard.gibson@gmail.com>2013-04-24 11:38:23 -0400
commit6a816ec95fd96d130a4af67a28873d9daa66a328 (patch)
treee5e84d1cca97bdfc617accdf9af942fcf25d3177
parent7723012e1118924171fc5b015a6e210712446eb7 (diff)
downloadjquery-6a816ec95fd96d130a4af67a28873d9daa66a328.tar.gz
jquery-6a816ec95fd96d130a4af67a28873d9daa66a328.zip
Fix #13819: .parent sort direction
-rw-r--r--src/traversing.js2
-rw-r--r--test/unit/traversing.js26
2 files changed, 27 insertions, 1 deletions
diff --git a/src/traversing.js b/src/traversing.js
index a9c9c9796..c1798a44f 100644
--- a/src/traversing.js
+++ b/src/traversing.js
@@ -201,7 +201,7 @@ jQuery.each({
}
// Reverse order for parents* and prev*
- if ( name.charAt(0) === "p" ) {
+ if ( name.charAt(0) === "p" && name !== "parent" ) {
ret = ret.reverse();
}
}
diff --git a/test/unit/traversing.js b/test/unit/traversing.js
index b98abdcd4..a622ba902 100644
--- a/test/unit/traversing.js
+++ b/test/unit/traversing.js
@@ -673,6 +673,32 @@ test("contents()", function() {
equal( c[0].nodeValue, "hi", "Check node,textnode,comment contents is just the one from span" );
});
+test("sort direction", function() {
+ expect( 12 );
+
+ var elems = jQuery("#ap, #select1 > *, #moretests > form"),
+ methodDirections = {
+ parent: false,
+ parents: true,
+ parentsUntil: true,
+ next: false,
+ prev: true,
+ nextAll: false,
+ prevAll: true,
+ nextUntil: false,
+ prevUntil: true,
+ siblings: false,
+ children: false,
+ contents: false
+ };
+
+ jQuery.each( methodDirections, function( method, reversed ) {
+ var actual = elems[ method ]().get(),
+ forward = jQuery.unique( [].concat( actual ) );
+ deepEqual( actual, reversed ? forward.reverse() : forward, "Correct sort direction for " + method );
+ });
+});
+
test("add(String|Element|Array|undefined)", function() {
expect( 15 );