Removed the need for the results set to have array methods. Resolves jQuery bug #4250.
This commit is contained in:
parent
f094c803de
commit
58235cc38e
2 changed files with 13 additions and 15 deletions
11
src/core.js
11
src/core.js
|
@ -279,14 +279,9 @@ jQuery.fn = jQuery.prototype = {
|
||||||
return this.prevObject || jQuery(null);
|
return this.prevObject || jQuery(null);
|
||||||
},
|
},
|
||||||
|
|
||||||
// For internal use only.
|
|
||||||
// Behaves like an Array's method, not like a jQuery method.
|
|
||||||
push: [].push,
|
|
||||||
sort: [].sort,
|
|
||||||
splice: [].splice,
|
|
||||||
|
|
||||||
find: function( selector ) {
|
find: function( selector ) {
|
||||||
var ret = this.pushStack( "", "find", selector ), length = 0;
|
var ret = this.pushStack( "", "find", selector ), length = 0,
|
||||||
|
splice = Array.prototype.splice;
|
||||||
|
|
||||||
for ( var i = 0, l = this.length; i < l; i++ ) {
|
for ( var i = 0, l = this.length; i < l; i++ ) {
|
||||||
length = ret.length;
|
length = ret.length;
|
||||||
|
@ -297,7 +292,7 @@ jQuery.fn = jQuery.prototype = {
|
||||||
for ( var n = length; n < ret.length; n++ ) {
|
for ( var n = length; n < ret.length; n++ ) {
|
||||||
for ( var r = 0; r < length; r++ ) {
|
for ( var r = 0; r < length; r++ ) {
|
||||||
if ( ret[r] === ret[n] ) {
|
if ( ret[r] === ret[n] ) {
|
||||||
ret.splice(n--, 1);
|
splice.call(ret, n--, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,10 @@
|
||||||
|
|
||||||
var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g,
|
var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g,
|
||||||
done = 0,
|
done = 0,
|
||||||
toString = Object.prototype.toString;
|
toString = Object.prototype.toString,
|
||||||
|
arraySplice = Array.prototype.splice,
|
||||||
|
arrayPush = Array.prototype.push,
|
||||||
|
arraySort = Array.prototype.sort;
|
||||||
|
|
||||||
var Sizzle = function(selector, context, results, seed) {
|
var Sizzle = function(selector, context, results, seed) {
|
||||||
results = results || [];
|
results = results || [];
|
||||||
|
@ -104,17 +107,17 @@ var Sizzle = function(selector, context, results, seed) {
|
||||||
|
|
||||||
if ( toString.call(checkSet) === "[object Array]" ) {
|
if ( toString.call(checkSet) === "[object Array]" ) {
|
||||||
if ( !prune ) {
|
if ( !prune ) {
|
||||||
results.push.apply( results, checkSet );
|
arrayPush.apply( results, checkSet );
|
||||||
} else if ( context && context.nodeType === 1 ) {
|
} else if ( context && context.nodeType === 1 ) {
|
||||||
for ( var i = 0; checkSet[i] != null; i++ ) {
|
for ( var i = 0; checkSet[i] != null; i++ ) {
|
||||||
if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) {
|
if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) {
|
||||||
results.push( set[i] );
|
arrayPush.call( results, set[i] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for ( var i = 0; checkSet[i] != null; i++ ) {
|
for ( var i = 0; checkSet[i] != null; i++ ) {
|
||||||
if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
|
if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
|
||||||
results.push( set[i] );
|
arrayPush.call( results, set[i] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,12 +136,12 @@ var Sizzle = function(selector, context, results, seed) {
|
||||||
Sizzle.uniqueSort = function(results){
|
Sizzle.uniqueSort = function(results){
|
||||||
if ( sortOrder ) {
|
if ( sortOrder ) {
|
||||||
hasDuplicate = false;
|
hasDuplicate = false;
|
||||||
results.sort(sortOrder);
|
arraySort.call(results, sortOrder);
|
||||||
|
|
||||||
if ( hasDuplicate ) {
|
if ( hasDuplicate ) {
|
||||||
for ( var i = 1; i < results.length; i++ ) {
|
for ( var i = 1; i < results.length; i++ ) {
|
||||||
if ( results[i] === results[i-1] ) {
|
if ( results[i] === results[i-1] ) {
|
||||||
results.splice(i--, 1);
|
arraySplice.call(results, i--, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -663,7 +666,7 @@ var makeArray = function(array, results) {
|
||||||
array = Array.prototype.slice.call( array );
|
array = Array.prototype.slice.call( array );
|
||||||
|
|
||||||
if ( results ) {
|
if ( results ) {
|
||||||
results.push.apply( results, array );
|
arrayPush.apply( results, array );
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue