Skip to content
Permalink
Browse files

Made some changes to how .find() works, inlined the duplicate check -…

… should change other methods to act similarly. Goes towards fixing #4240.
  • Loading branch information...
jeresig committed Feb 25, 2009
1 parent 4bbb70b commit f094c803deba3c35c66f9dc0923db800fb088753
Showing with 18 additions and 10 deletions.
  1. +18 −10 src/core.js
@@ -286,18 +286,26 @@ jQuery.fn = jQuery.prototype = {
splice: [].splice,

find: function( selector ) {
if ( this.length === 1 ) {
var ret = this.pushStack( "", "find", selector );
jQuery.find( selector, this[0], ret );
return ret;
} else {
var ret = this.pushStack( "", "find", selector );
for ( var i = 0, l = this.length; i < l; i++ ) {
jQuery.find( selector, this[i], ret );
var ret = this.pushStack( "", "find", selector ), length = 0;

for ( var i = 0, l = this.length; i < l; i++ ) {
length = ret.length;
jQuery.find( selector, this[i], ret );

if ( i > 0 ) {
// 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 ) {

0 comments on commit f094c80

Please sign in to comment.
You can’t perform that action at this time.