10000 Core: Remove private copies of push, sort & splice from the jQuery pr… · jquery/jquery@b59107f · GitHub
[go: up one dir, main page]

Skip to content

Commit b59107f

Browse files
authored
Core: Remove private copies of push, sort & splice from the jQuery prototype
Closes gh-4473
1 parent 78420d4 commit b59107f

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

src/core.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,7 @@ jQuery.fn = jQuery.prototype = {
120120

121121
end: function() {
122122
return this.prevObject || this.constructor();
123-
},
124-
125-
// For internal use only.
126-
// Behaves like an Array's method, not like a jQuery method.
127-
push: push,
128-
sort: arr.sort,
129-
splice: arr.splice
123+
}
130124
};
131125

132126
jQuery.extend = jQuery.fn.extend = function() {

src/selector.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ function find( selector, context, results, seed ) {
190190
// Document context
191191
if ( nodeType === 9 ) {
192192
if ( ( elem = context.getElementById( m ) ) ) {
193-
results.push( elem );
193+
push.call( results, elem );
194194
}
195195
return results;
196196

@@ -199,7 +199,7 @@ function find( selector, context, results, seed ) {
199199
if ( newContext && ( elem = newContext.getElementById( m ) ) &&
200200
jQuery.contains( context, elem ) ) {
201201

202-
results.push( elem );
202+
push.call( results, elem );
203203
return results;
204204
}
205205
}
@@ -1426,7 +1426,7 @@ function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
14261426
}
14271427
while ( ( matcher = elementMatchers[ j++ ] ) ) {
14281428
if ( matcher( elem, context || document, xml ) ) {
1429-
results.push( elem );
1429+
push.call( results, elem );
14301430
break;
14311431
}
14321432
}

src/selector/uniqueSort.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
define( [
22
"../core",
3-
"../var/document"
4-
], function( jQuery, document ) {
3+
"../var/document",
4+
"../var/sort"
5+
], function( jQuery, document, sort ) {
56

67
"use strict";
78

@@ -61,7 +62,7 @@ jQuery.uniqueSort = function( results ) {
6162

6263
hasDuplicate = false;
6364

64-
results.sort( sortOrder );
65+
sort.call( results, sortOrder );
6566

6667
if ( hasDuplicate ) {
6768
while ( ( elem = results[ i++ ] ) ) {

src/var/sort.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
define( [
2+
"./arr"
3+
], function( arr ) {
4+
"use strict";
5+
6+
return arr.sort;
7+
} );

0 commit comments

Comments
 (0)
0