X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fselector.js;h=51f165a0c296ee4c577b6039318141815da7bfd1;hb=3bb82a34de18b8b8e80893571d65080bf5a4702b;hp=da2724530eb00a5e4964c70a3beb3ff574dd4781;hpb=7cdddebe047302f51c4fd30823565f3ac1553d60;p=jquery.git diff --git a/src/selector.js b/src/selector.js index da27245..51f165a 100644 --- a/src/selector.js +++ b/src/selector.js @@ -96,9 +96,9 @@ jQuery.extend({ if ( typeof t != "string" ) return [ t ]; - // Make sure that the context is a DOM Element - if ( context && !context.nodeType ) - context = null; + // check to make sure context is a DOM element or a document + if ( context && context.nodeType != 1 && context.nodeType != 9) + return [ ]; // Set the correct context (if none is provided) context = context || document; @@ -320,7 +320,10 @@ jQuery.extend({ // :not() is a special case that can be optimized by // keeping it out of the expression list if ( m[1] == ":" && m[2] == "not" ) - r = jQuery.filter(m[3], r, true).r; + // optimize if only one selector found (most common case) + r = isSimple.test( m[3] ) ? + jQuery.filter(m[3], r, true).r : + jQuery( r ).not( m[3] ); // We can get a big speed boost by filtering by class here else if ( m[1] == "." )