]> source.dussan.org Git - jquery.git/commitdiff
Fixes #7369 - Using an attribute selector for a non-existent attribute raised an... 291/head
authortimmywil <tim.willison@thisismedium.com>
Thu, 31 Mar 2011 03:39:19 +0000 (23:39 -0400)
committertimmywil <tim.willison@thisismedium.com>
Thu, 31 Mar 2011 03:39:19 +0000 (23:39 -0400)
src/traversing.js
test/unit/traversing.js

index fe2e33d88a257c252d6b560b56143a57ee12f034..468aa097ffbb51dea033761e1ea6ad6bf70e3464 100644 (file)
@@ -112,7 +112,7 @@ jQuery.fn.extend({
 
                                } else {
                                        cur = cur.parentNode;
-                                       if ( !cur || !cur.ownerDocument || cur === context ) {
+                                       if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) {
                                                break;
                                        }
                                }
index f5108bdef3abcda87db161766d54c655c814910c..4cccd650f3a03333c00628501119ff57e1c5fa3e 100644 (file)
@@ -124,7 +124,7 @@ test("filter(jQuery)", function() {
 })
 
 test("closest()", function() {
-       expect(11);
+       expect(13);
        same( jQuery("body").closest("body").get(), q("body"), "closest(body)" );
        same( jQuery("body").closest("html").get(), q("html"), "closest(html)" );
        same( jQuery("body").closest("div").get(), [], "closest(div)" );
@@ -144,6 +144,10 @@ test("closest()", function() {
 
        // Test on disconnected node
        equals( jQuery("<div><p></p></div>").find("p").closest("table").length, 0, "Make sure disconnected closest work." );
+
+       // Bug #7369
+       equals( jQuery('<div foo="bar"></div>').closest('[foo]').length, 1, "Disconnected nodes with attribute selector" );
+       equals( jQuery('<div>text</div>').closest('[lang]').length, 0, "Disconnected nodes with text and non-existent attribute selector" );
 });
 
 test("closest(Array)", function() {