From cde4c326b82af4679026a202f02799e9fbd18cb4 Mon Sep 17 00:00:00 2001 From: Dave Methvin Date: Tue, 26 Jun 2012 17:08:49 -0400 Subject: [PATCH] Fix #11969. Never a null moment when checking siblings. --- src/traversing.js | 2 +- test/unit/traversing.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/traversing.js b/src/traversing.js index b13b06c97..0cca81a0a 100644 --- a/src/traversing.js +++ b/src/traversing.js @@ -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; } diff --git a/test/unit/traversing.js b/test/unit/traversing.js index 9d8900ee7..2712e7f2f 100644 --- a/test/unit/traversing.js +++ b/test/unit/traversing.js @@ -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() { -- 2.39.5