From 28ce15979f69903f2fe1187705b190968757ddf7 Mon Sep 17 00:00:00 2001 From: Ben Alman Date: Thu, 21 Jan 2010 09:10:34 +0800 Subject: [PATCH] fixed jQuery.dir regression introduced with 1.4 *untils patch that errored when traversing XHTML text nodes with an until test --- src/traversing.js | 2 +- test/unit/traversing.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/traversing.js b/src/traversing.js index d0dd52d..bf17b8a 100644 --- a/src/traversing.js +++ b/src/traversing.js @@ -235,7 +235,7 @@ jQuery.extend({ dir: function( elem, dir, until ) { var matched = [], cur = elem[dir]; - while ( cur && cur.nodeType !== 9 && (until === undefined || !jQuery( cur ).is( until )) ) { + while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) { if ( cur.nodeType === 1 ) { matched.push( cur ); } diff --git a/test/unit/traversing.js b/test/unit/traversing.js index f406ac7..d297ce3 100644 --- a/test/unit/traversing.js +++ b/test/unit/traversing.js @@ -317,7 +317,7 @@ test("prevAll([String])", function() { }); test("nextUntil([String])", function() { - expect(10); + expect(11); var elems = jQuery('#form').children().slice( 2, 12 ); @@ -331,6 +331,8 @@ test("nextUntil([String])", function() { same( jQuery("#text1").nextUntil("#area1", "button,input").get(), elems.get(), "Multiple-filtered nextUntil check" ); equals( jQuery("#text1").nextUntil("#area1", "div").length, 0, "Filtered nextUntil check, no match" ); same( jQuery("#text1, #hidden1").nextUntil("#area1", "button,input").get(), elems.get(), "Multi-source, multiple-filtered nextUntil check" ); + + same( jQuery("#text1").nextUntil("[class=foo]").get(), jQuery("#text1").nextAll().get(), "Non-element nodes must be skipped, since they have no attributes" ); }); test("prevUntil([String])", function() { -- 1.7.10.4