Core: Remove private copies of push, sort & splice from the jQuery prototype

Closes gh-4473
This commit is contained in:
Michał Gołębiowski-Owczarek 2019-09-24 02:12:36 +02:00 committed by GitHub
parent 78420d427c
commit b59107f5d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 13 deletions

View File

@ -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() {

View File

@ -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;
}
}

View File

@ -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++ ] ) ) {

7
src/var/sort.js Normal file
View File

@ -0,0 +1,7 @@
define( [
"./arr"
], function( arr ) {
"use strict";
return arr.sort;
} );