Commit a807451a authored by timmywil's avatar timmywil

Fixes #7369 - Using an attribute selector for a non-existent attribute raised...

Fixes #7369 - Using an attribute selector for a non-existent attribute raised an exception on disconnected nodes
parent 6c28a394
...@@ -112,7 +112,7 @@ jQuery.fn.extend({ ...@@ -112,7 +112,7 @@ jQuery.fn.extend({
} else { } else {
cur = cur.parentNode; cur = cur.parentNode;
if ( !cur || !cur.ownerDocument || cur === context ) { if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) {
break; break;
} }
} }
......
...@@ -124,7 +124,7 @@ test("filter(jQuery)", function() { ...@@ -124,7 +124,7 @@ test("filter(jQuery)", function() {
}) })
test("closest()", function() { test("closest()", function() {
expect(11); expect(13);
same( jQuery("body").closest("body").get(), q("body"), "closest(body)" ); same( jQuery("body").closest("body").get(), q("body"), "closest(body)" );
same( jQuery("body").closest("html").get(), q("html"), "closest(html)" ); same( jQuery("body").closest("html").get(), q("html"), "closest(html)" );
same( jQuery("body").closest("div").get(), [], "closest(div)" ); same( jQuery("body").closest("div").get(), [], "closest(div)" );
...@@ -144,6 +144,10 @@ test("closest()", function() { ...@@ -144,6 +144,10 @@ test("closest()", function() {
// Test on disconnected node // Test on disconnected node
equals( jQuery("<div><p></p></div>").find("p").closest("table").length, 0, "Make sure disconnected closest work." ); 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() { test("closest(Array)", function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment