X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fjquery%2Fjquery.js;h=cc0af5212b8d6a443496008a24d1b18b109dfef5;hb=f2ff0db0320cfab0d856ff68d012cb843c97b600;hp=401fd142d80ea45651de7ab67b2cdbc22d70517a;hpb=ee0175c4b9d665322ac496dfcc6f8b0cc70b3c35;p=jquery.git diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js index 401fd14..cc0af52 100644 --- a/src/jquery/jquery.js +++ b/src/jquery/jquery.js @@ -812,21 +812,21 @@ jQuery.fn = jQuery.prototype = { * match the specified expression(s). This method is used to narrow down * the results of a search. * - * Provide a String array of expressions to apply multiple filters at once. + * Provide a comma-separated list of expressions to apply multiple filters at once. * * @example $("p").filter(".selected") * @before

Hello

How are you?

* @result [

Hello

] * @desc Selects all paragraphs and removes those without a class "selected". * - * @example $("p").filter([".selected", ":first"]) + * @example $("p").filter(".selected, :first") * @before

Hello

Hello Again

And Again

* @result [

Hello

,

And Again

] * @desc Selects all paragraphs and removes those without class "selected" and being the first one. * * @name filter * @type jQuery - * @param String|Array expression Expression(s) to search with. + * @param String expression Expression(s) to search with. * @cat DOM/Traversing */ @@ -849,21 +849,12 @@ jQuery.fn = jQuery.prototype = { */ filter: function(t) { return this.pushStack( - t.constructor == Array && - jQuery.map(this,function(a){ - for ( var i = 0, tl = t.length; i < tl; i++ ) - if ( jQuery.filter(t[i],[a]).r.length ) - return a; - return null; + t.constructor == Function && + jQuery.grep(this, function(el, index){ + return t.apply(el, [index]) }) || - t.constructor == Boolean && - ( t ? this.get() : [] ) || - - typeof t == "function" && - jQuery.grep( this, function(el, index) { return t.apply(el, [index]) }) || - - jQuery.filter(t,this).r ); + jQuery.multiFilter(t,this) ); }, /** @@ -896,10 +887,33 @@ jQuery.fn = jQuery.prototype = { * @param String expr An expression with which to remove matching elements * @cat DOM/Traversing */ + + /** + * Removes any elements inside the array of elements from the set + * of matched elements. This method is used to remove one or more + * elements from a jQuery object. + * + * @example $("p").not( $("div p.selected") ) + * @before

Hello

Hello Again

+ * @result [

Hello

] + * @desc Removes all elements that match "div p.selected" from the total set of all paragraphs. + * + * @name not + * @type jQuery + * @param Array|jQuery elems A set of elements to remove from the jQuery set of matched elements. + * @cat DOM/Traversing + */ not: function(t) { - return this.pushStack( typeof t == "string" ? - jQuery.filter(t,this,true).r : - jQuery.grep(this,function(a){ return a != t; }) ); + return this.pushStack( + t.constructor == String && + jQuery.multiFilter(t,this,true) || + + jQuery.grep(this,function(a){ + if ( t.constructor == Array || t.jquery ) + return !jQuery.inArray( t, a ); + else + return a != t; + }) ); }, /** @@ -1007,7 +1021,9 @@ jQuery.fn = jQuery.prototype = { * @cat DOM/Attributes */ val: function( val ) { - return val == undefined ? ( this.length ? this[0].value : null ) : this.attr( "value", val ); + return val == undefined ? + ( this.length ? this[0].value : null ) : + this.attr( "value", val ); }, /** @@ -1037,7 +1053,9 @@ jQuery.fn = jQuery.prototype = { * @cat DOM/Attributes */ html: function( val ) { - return val == undefined ? ( this.length ? this[0].innerHTML : null ) : this.empty().append( val ); + return val == undefined ? + ( this.length ? this[0].innerHTML : null ) : + this.empty().append( val ); }, /** @@ -1828,7 +1846,7 @@ jQuery.each({ jQuery.fn[ i ] = function(a) { var ret = jQuery.map(this,n); if ( a && typeof a == "string" ) - ret = jQuery.filter(a,ret).r; + ret = jQuery.multiFilter(a,ret); return this.pushStack( ret ); }; });