]> source.dussan.org Git - jquery.git/commitdiff
Merge branch '2773_find_closest' of https://github.com/timmywil/jquery into timmywil...
authorjeresig <jeresig@gmail.com>
Sun, 10 Apr 2011 20:37:09 +0000 (16:37 -0400)
committerjeresig <jeresig@gmail.com>
Sun, 10 Apr 2011 20:37:09 +0000 (16:37 -0400)
Conflicts:
test/unit/traversing.js

1  2 
src/core.js
src/traversing.js
test/unit/traversing.js

diff --cc src/core.js
Simple merge
Simple merge
index 7d15f4c18491c85c4504c45dbe29b887bcd668f6,117e460003c7b52fa94b338cff27d69edb7b8df3..71bc7f5d52d283a903b0b985e83f079a7b68dbb0
@@@ -13,8 -13,32 +13,32 @@@ test("find(String)", function() 
        same( jQuery("#main").find("> #foo > p").get(), q("sndp", "en", "sap"), "find child elements" );
  });
  
 -test("is(String)", function() {
 -      expect(26);
+ test("find(node|jQuery object)", function() {
+       expect( 11 );
+       
+       var $foo = jQuery('#foo'),
+               $blog = jQuery('.blogTest'),
+               $first = jQuery('#first'),
+               $two = $blog.add( $first ),
+               $fooTwo = $foo.add( $blog );
+       equals( $foo.find( $blog ).text(), 'Yahoo', 'Find with blog jQuery object' );
+       equals( $foo.find( $blog[0] ).text(), 'Yahoo', 'Find with blog node' );
+       equals( $foo.find( $first ).length, 0, '#first is not in #foo' );
+       equals( $foo.find( $first[0]).length, 0, '#first not in #foo (node)' );
+       ok( $foo.find( $two ).is('.blogTest'), 'Find returns only nodes within #foo' );
+       ok( $fooTwo.find( $blog ).is('.blogTest'), 'Blog is part of the collection, but also within foo' );
+       ok( $fooTwo.find( $blog[0] ).is('.blogTest'), 'Blog is part of the collection, but also within foo(node)' );
+       
+       equals( $two.find( $foo ).length, 0, 'Foo is not in two elements' );
+       equals( $two.find( $foo[0] ).length, 0, 'Foo is not in two elements(node)' );
+       equals( $two.find( $first ).length, 0, 'first is in the collection and not within two' );
+       equals( $two.find( $first ).length, 0, 'first is in the collection and not within two(node)' );
+       
+ });
 +test("is(String|undefined)", function() {
 +      expect(27);
        ok( jQuery('#form').is('form'), 'Check for element: A form must be a form' );
        ok( !jQuery('#form').is('div'), 'Check for element: A form is not a div' );
        ok( jQuery('#mark').is('.blog'), 'Check for class: Expected class "blog"' );
@@@ -195,8 -182,24 +219,29 @@@ test("closest(Array)", function() 
        same( jQuery("body").closest(["span","html"]), [{selector:"html", elem:document.documentElement, level:2}], "closest([body, html])" );
  });
  
++<<<<<<< HEAD
 +test("not(Selector|undefined)", function() {
 +      expect(11);
++=======
+ test("closest(jQuery)", function() {
+       expect(8);
+       var $child = jQuery("#nothiddendivchild"),
+               $parent = jQuery("#nothiddendiv"),
+               $main = jQuery("#main"),
+               $body = jQuery("body");
+       ok( $child.closest( $parent ).is('#nothiddendiv'), "closest( jQuery('#nothiddendiv') )" );
+       ok( $child.closest( $parent[0] ).is('#nothiddendiv'), "closest( jQuery('#nothiddendiv') ) :: node" );
+       ok( $child.closest( $child ).is('#nothiddendivchild'), "child is included" );
+       ok( $child.closest( $child[0] ).is('#nothiddendivchild'), "child is included  :: node" );
+       equals( $child.closest( document.createElement('div') ).length, 0, "created element is not related" );
+       equals( $child.closest( $main ).length, 0, "Main not a parent of child" );
+       equals( $child.closest( $main[0] ).length, 0, "Main not a parent of child :: node" );
+       ok( $child.closest( $body.add($parent) ).is('#nothiddendiv'), "Closest ancestor retrieved." );
+ });
+ test("not(Selector)", function() {
+       expect(7);
++>>>>>>> 1a167767305202797cf4c839eb64bd7adfb00182
        equals( jQuery("#main > p#ap > a").not("#google").length, 2, "not('selector')" );
        same( jQuery("p").not(".result").get(), q("firstp", "ap", "sndp", "en", "sap", "first"), "not('.class')" );
        same( jQuery("p").not("#ap, #sndp, .result").get(), q("firstp", "en", "sap", "first"), "not('selector, selector')" );