Skip to content

Commit a0d37f8

Browse files
committed
fixed jQuery.dir regression introduced with 1.4 *untils patch that errored when traversing XHTML text nodes with an until test
1 parent 435772e commit a0d37f8

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/traversing.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ jQuery.extend({
235235

236236
dir: function( elem, dir, until ) {
237237
var matched = [], cur = elem[dir];
238-
while ( cur && cur.nodeType !== 9 && (until === undefined || !jQuery( cur ).is( until )) ) {
238+
while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
239239
if ( cur.nodeType === 1 ) {
240240
matched.push( cur );
241241
}

test/unit/traversing.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ test("prevAll([String])", function() {
317317
});
318318

319319
test("nextUntil([String])", function() {
320-
expect(10);
320+
expect(11);
321321

322322
var elems = jQuery('#form').children().slice( 2, 12 );
323323

@@ -331,6 +331,8 @@ test("nextUntil([String])", function() {
331331
same( jQuery("#text1").nextUntil("#area1", "button,input").get(), elems.get(), "Multiple-filtered nextUntil check" );
332332
equals( jQuery("#text1").nextUntil("#area1", "div").length, 0, "Filtered nextUntil check, no match" );
333333
same( jQuery("#text1, #hidden1").nextUntil("#area1", "button,input").get(), elems.get(), "Multi-source, multiple-filtered nextUntil check" );
334+
335+
same( jQuery("#text1").nextUntil("[class=foo]").get(), jQuery("#text1").nextAll().get(), "Non-element nodes must be skipped, since they have no attributes" );
334336
});
335337

336338
test("prevUntil([String])", function() {

0 commit comments

Comments
 (0)