diff options
author | Richard Gibson <richard.gibson@gmail.com> | 2012-04-02 13:12:57 -0400 |
---|---|---|
committer | Dave Methvin <dave.methvin@gmail.com> | 2012-04-05 21:03:41 -0400 |
commit | 590bcab245d969dffc3c61b7679ab4d1a9a26ebd (patch) | |
tree | 9234c53cadc00d1525748f90e8be32a6140aec9e /test/unit/traversing.js | |
parent | c04bfce556616a60cecf0ecaf9cb1f9d048a4747 (diff) | |
download | jquery-590bcab245d969dffc3c61b7679ab4d1a9a26ebd.tar.gz jquery-590bcab245d969dffc3c61b7679ab4d1a9a26ebd.zip |
Fix #11543: .has should work on detached elements.
Diffstat (limited to 'test/unit/traversing.js')
-rw-r--r-- | test/unit/traversing.js | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/test/unit/traversing.js b/test/unit/traversing.js index 8e8b5360a..80d30aa19 100644 --- a/test/unit/traversing.js +++ b/test/unit/traversing.js @@ -370,21 +370,27 @@ test("not(jQuery)", function() { }); test("has(Element)", function() { - expect(2); + expect(3); var obj = jQuery("#qunit-fixture").has(jQuery("#sndp")[0]); deepEqual( obj.get(), q("qunit-fixture"), "Keeps elements that have the element as a descendant" ); + var detached = jQuery("<a><b><i/></b></a>"); + deepEqual( detached.has( detached.find("i")[0] ).get(), detached.get(), "...Even when detached" ); + var multipleParent = jQuery("#qunit-fixture, #header").has(jQuery("#sndp")[0]); deepEqual( obj.get(), q("qunit-fixture"), "Does not include elements that do not have the element as a descendant" ); }); test("has(Selector)", function() { - expect(3); + expect(4); var obj = jQuery("#qunit-fixture").has("#sndp"); deepEqual( obj.get(), q("qunit-fixture"), "Keeps elements that have any element matching the selector as a descendant" ); + var detached = jQuery("<a><b><i/></b></a>"); + deepEqual( detached.has("i").get(), detached.get(), "...Even when detached" ); + var multipleParent = jQuery("#qunit-fixture, #header").has("#sndp"); deepEqual( obj.get(), q("qunit-fixture"), "Does not include elements that do not have the element as a descendant" ); @@ -393,11 +399,14 @@ test("has(Selector)", function() { }); test("has(Arrayish)", function() { - expect(3); + expect(4); var simple = jQuery("#qunit-fixture").has(jQuery("#sndp")); deepEqual( simple.get(), q("qunit-fixture"), "Keeps elements that have any element in the jQuery list as a descendant" ); + var detached = jQuery("<a><b><i/></b></a>"); + deepEqual( detached.has( detached.find("i") ).get(), detached.get(), "...Even when detached" ); + var multipleParent = jQuery("#qunit-fixture, #header").has(jQuery("#sndp")); deepEqual( multipleParent.get(), q("qunit-fixture"), "Does not include elements that do not have an element in the jQuery list as a descendant" ); |