Commit f094c803 authored by John Resig's avatar John Resig

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

Made some changes to how .find() works, inlined the duplicate check - should change other methods to act similarly. Goes towards fixing #4240.
parent 4bbb70b4
...@@ -286,18 +286,26 @@ jQuery.fn = jQuery.prototype = { ...@@ -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 );
return ret;
} else {
var ret = this.pushStack( "", "find", selector );
for ( var i = 0, l = this.length; i < l; i++ ) { for ( var i = 0, l = this.length; i < l; i++ ) {
length = ret.length;
jQuery.find( selector, this[i], ret ); 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 ) { clone: function( events ) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment