]> source.dussan.org Git - jquery.git/commitdiff
Fixed #2062 by adding a check to see if the selector is array-like in .not() before...
authorDavid Serduke <davidserduke@gmail.com>
Mon, 17 Dec 2007 16:54:44 +0000 (16:54 +0000)
committerDavid Serduke <davidserduke@gmail.com>
Mon, 17 Dec 2007 16:54:44 +0000 (16:54 +0000)
src/core.js
test/unit/core.js

index c7f30d6de66d02a2b3560d49ea59dfa2d7ee58f0..1ec8de057ffbf38fb93dd46c98e83541a8e2cc13 100644 (file)
@@ -353,7 +353,10 @@ jQuery.fn = jQuery.prototype = {
                                selector = jQuery.multiFilter( selector, this );
 
                return this.filter(function() {
-                       return jQuery.inArray( this, selector ) < 0;
+                       // check to see if the selector is array-like otherwise assume it is just a DOM element
+                       return ( selector.length && selector[selector.length - 1] !== undefined )
+                               ? jQuery.inArray( this, selector ) < 0
+                               : this != selector;
                });
        },
 
index 088726ff7c20f97767e745d095f6993fb8ab63b3..ea687c8f8fad5b90a66048e494b64091188bf3cc 100644 (file)
@@ -1058,11 +1058,13 @@ test("filter()", function() {
 });
 
 test("not()", function() {
-       expect(5);
+       expect(7);
        ok( $("#main > p#ap > a").not("#google").length == 2, "not('selector')" );
+       ok( $("#main > p#ap > a").not(document.getElementById("google")).length == 2, "not(DOMElement)" );
        isSet( $("p").not(".result").get(), q("firstp", "ap", "sndp", "en", "sap", "first"), "not('.class')" );
        isSet( $("p").not("#ap, #sndp, .result").get(), q("firstp", "en", "sap", "first"), "not('selector, selector')" );
        isSet( $("p").not($("#ap, #sndp, .result")).get(), q("firstp", "en", "sap", "first"), "not(jQuery)" );
+       ok( $("p").not(document.getElementsByTagName("p")).length == 0, "not(Array-like DOM collection)" );
        isSet( $("#form option").not("option.emptyopt:contains('Nothing'),[selected],[value='1']").get(), q("option1c", "option1d", "option2c", "option3d" ), "not('complex selector')");
 });