mirror of
https://github.com/jquery/jquery.git
synced 2025-01-10 18:24:24 +00:00
No ticket: Reduce .find
This commit is contained in:
parent
157aeb7c37
commit
85b3c82445
@ -10,11 +10,12 @@ var isSimple = /^.[^:#\[\.,]*$/,
|
|||||||
|
|
||||||
jQuery.fn.extend({
|
jQuery.fn.extend({
|
||||||
find: function( selector ) {
|
find: function( selector ) {
|
||||||
var i, ret, self,
|
var i,
|
||||||
len = this.length;
|
ret = [],
|
||||||
|
self = this,
|
||||||
|
len = self.length;
|
||||||
|
|
||||||
if ( typeof selector !== "string" ) {
|
if ( typeof selector !== "string" ) {
|
||||||
self = this;
|
|
||||||
return this.pushStack( jQuery( selector ).filter(function() {
|
return this.pushStack( jQuery( selector ).filter(function() {
|
||||||
for ( i = 0; i < len; i++ ) {
|
for ( i = 0; i < len; i++ ) {
|
||||||
if ( jQuery.contains( self[ i ], this ) ) {
|
if ( jQuery.contains( self[ i ], this ) ) {
|
||||||
@ -24,14 +25,13 @@ jQuery.fn.extend({
|
|||||||
}) );
|
}) );
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = [];
|
|
||||||
for ( i = 0; i < len; i++ ) {
|
for ( i = 0; i < len; i++ ) {
|
||||||
jQuery.find( selector, this[ i ], ret );
|
jQuery.find( selector, self[ i ], ret );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Needed because $( selector, context ) becomes $( context ).find( selector )
|
// Needed because $( selector, context ) becomes $( context ).find( selector )
|
||||||
ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
|
ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
|
||||||
ret.selector = ( this.selector ? this.selector + " " : "" ) + selector;
|
ret.selector = this.selector ? this.selector + " " + selector : selector;
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user