diff --git a/src/core.js b/src/core.js index 6dbc69eb0..0999da9f5 100644 --- a/src/core.js +++ b/src/core.js @@ -120,13 +120,7 @@ jQuery.fn = jQuery.prototype = { end: function() { return this.prevObject || this.constructor(); - }, - - // For internal use only. - // Behaves like an Array's method, not like a jQuery method. - push: push, - sort: arr.sort, - splice: arr.splice + } }; jQuery.extend = jQuery.fn.extend = function() { diff --git a/src/selector.js b/src/selector.js index 847d3a448..fbfa7d1d8 100644 --- a/src/selector.js +++ b/src/selector.js @@ -190,7 +190,7 @@ function find( selector, context, results, seed ) { // Document context if ( nodeType === 9 ) { if ( ( elem = context.getElementById( m ) ) ) { - results.push( elem ); + push.call( results, elem ); } return results; @@ -199,7 +199,7 @@ function find( selector, context, results, seed ) { if ( newContext && ( elem = newContext.getElementById( m ) ) && jQuery.contains( context, elem ) ) { - results.push( elem ); + push.call( results, elem ); return results; } } @@ -1426,7 +1426,7 @@ function matcherFromGroupMatchers( elementMatchers, setMatchers ) { } while ( ( matcher = elementMatchers[ j++ ] ) ) { if ( matcher( elem, context || document, xml ) ) { - results.push( elem ); + push.call( results, elem ); break; } } diff --git a/src/selector/uniqueSort.js b/src/selector/uniqueSort.js index cf70d5c1a..a0454812a 100644 --- a/src/selector/uniqueSort.js +++ b/src/selector/uniqueSort.js @@ -1,7 +1,8 @@ define( [ "../core", - "../var/document" -], function( jQuery, document ) { + "../var/document", + "../var/sort" +], function( jQuery, document, sort ) { "use strict"; @@ -61,7 +62,7 @@ jQuery.uniqueSort = function( results ) { hasDuplicate = false; - results.sort( sortOrder ); + sort.call( results, sortOrder ); if ( hasDuplicate ) { while ( ( elem = results[ i++ ] ) ) { diff --git a/src/var/sort.js b/src/var/sort.js new file mode 100644 index 000000000..a943fa77c --- /dev/null +++ b/src/var/sort.js @@ -0,0 +1,7 @@ +define( [ + "./arr" +], function( arr ) { + "use strict"; + + return arr.sort; +} );