Made some changes to how .find() works, inlined the duplicate check - should change other methods to act similarly. Goes towards fixing #4240.
This commit is contained in:
parent
4bbb70b4eb
commit
f094c803de
28
src/core.js
28
src/core.js
|
@ -286,18 +286,26 @@ jQuery.fn = jQuery.prototype = {
|
||||||
splice: [].splice,
|
splice: [].splice,
|
||||||
|
|
||||||
find: function( selector ) {
|
find: function( selector ) {
|
||||||
if ( this.length === 1 ) {
|
var ret = this.pushStack( "", "find", selector ), length = 0;
|
||||||
var ret = this.pushStack( "", "find", selector );
|
|
||||||
jQuery.find( selector, this[0], ret );
|
for ( var i = 0, l = this.length; i < l; i++ ) {
|
||||||
return ret;
|
length = ret.length;
|
||||||
} else {
|
jQuery.find( selector, this[i], ret );
|
||||||
var ret = this.pushStack( "", "find", selector );
|
|
||||||
for ( var i = 0, l = this.length; i < l; i++ ) {
|
if ( i > 0 ) {
|
||||||
jQuery.find( selector, this[i], ret );
|
// Make sure that the results are unique
|
||||||
|
for ( var n = length; n < ret.length; n++ ) {
|
||||||
|
for ( var r = 0; r < length; r++ ) {
|
||||||
|
if ( ret[r] === ret[n] ) {
|
||||||
|
ret.splice(n--, 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//jQuery.find.uniqueSort( ret );
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
},
|
},
|
||||||
|
|
||||||
clone: function( events ) {
|
clone: function( events ) {
|
||||||
|
|
Loading…
Reference in a new issue