]> source.dussan.org Git - jquery.git/commitdiff
Fix #11969. Never a null moment when checking siblings.
authorDave Methvin <dave.methvin@gmail.com>
Tue, 26 Jun 2012 21:08:49 +0000 (17:08 -0400)
committerDave Methvin <dave.methvin@gmail.com>
Tue, 26 Jun 2012 21:08:49 +0000 (17:08 -0400)
src/traversing.js
test/unit/traversing.js

index b13b06c972c1d9d468dcd4e1b8ccffe0c73c9362..0cca81a0a5a18407f7c6eb62632cbc13460f80a2 100644 (file)
@@ -158,7 +158,7 @@ function isDisconnected( node ) {
 function sibling( cur, dir ) {
        do {
                cur = cur[ dir ];
-       } while ( cur.nodeType !== 1 );
+       } while ( cur && cur.nodeType !== 1 );
 
        return cur;
 }
index 9d8900ee70fb8b68262274f16a27480345e43bd8..2712e7f2fe2dd29946ae71e2d98db3a379143c27 100644 (file)
@@ -467,11 +467,12 @@ test("parentsUntil([String])", function() {
 });
 
 test("next([String])", function() {
-       expect(4);
+       expect(5);
        equal( jQuery("#ap").next()[0].id, "foo", "Simple next check" );
        equal( jQuery("#ap").next("div")[0].id, "foo", "Filtered next check" );
        equal( jQuery("#ap").next("p").length, 0, "Filtered next check, no match" );
        equal( jQuery("#ap").next("div, p")[0].id, "foo", "Multiple filters" );
+       equal( jQuery("body").next().length, 0, "Simple next check, no match" );
 });
 
 test("prev([String])", function() {