Commit 0a6c5205 authored by John Resig's avatar John Resig

Make sure that at least one argument is provided to .slice(), in accordance...

Make sure that at least one argument is provided to .slice(), in accordance with the spec. Fixes jQuery bug #4942.
parent b964e569
...@@ -128,7 +128,9 @@ jQuery.fn = jQuery.prototype = { ...@@ -128,7 +128,9 @@ jQuery.fn = jQuery.prototype = {
return this.length; return this.length;
}, },
toArray: slice, toArray: function(){
return slice.call( this, 0 );
},
// Get the Nth element in the matched element set OR // Get the Nth element in the matched element set OR
// Get the whole matched element set as a clean array // Get the whole matched element set as a clean array
......
...@@ -57,7 +57,7 @@ jQuery.event = { ...@@ -57,7 +57,7 @@ jQuery.event = {
// Namespaced event handlers // Namespaced event handlers
var namespaces = type.split("."); var namespaces = type.split(".");
type = namespaces.shift(); type = namespaces.shift();
handler.type = namespaces.slice().sort().join("."); handler.type = namespaces.slice(0).sort().join(".");
// Get the current list of functions bound to this event // Get the current list of functions bound to this event
var handlers = events[ type ], var handlers = events[ type ],
...@@ -133,7 +133,7 @@ jQuery.event = { ...@@ -133,7 +133,7 @@ jQuery.event = {
var namespaces = type.split("."); var namespaces = type.split(".");
type = namespaces.shift(); type = namespaces.shift();
var all = !namespaces.length, var all = !namespaces.length,
namespace = new RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)"), namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join(".*\\.") + "(\\.|$)"),
special = this.special[ type ] || {}; special = this.special[ type ] || {};
if ( events[ type ] ) { if ( events[ type ] ) {
...@@ -291,7 +291,7 @@ jQuery.event = { ...@@ -291,7 +291,7 @@ jQuery.event = {
// Cache this now, all = true means, any handler // Cache this now, all = true means, any handler
all = !namespaces.length && !event.exclusive; all = !namespaces.length && !event.exclusive;
var namespace = new RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)"); var namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join(".*\\.") + "(\\.|$)");
handlers = ( jQuery.data(this, "events") || {} )[ event.type ]; handlers = ( jQuery.data(this, "events") || {} )[ event.type ];
......
...@@ -661,7 +661,7 @@ for ( var type in Expr.match ) { ...@@ -661,7 +661,7 @@ for ( var type in Expr.match ) {
} }
var makeArray = function(array, results) { var makeArray = function(array, results) {
array = Array.prototype.slice.call( array ); array = Array.prototype.slice.call( array, 0 );
if ( results ) { if ( results ) {
results.push.apply( results, array ); results.push.apply( results, array );
...@@ -674,7 +674,7 @@ var makeArray = function(array, results) { ...@@ -674,7 +674,7 @@ var makeArray = function(array, results) {
// Perform a simple check to determine if the browser is capable of // Perform a simple check to determine if the browser is capable of
// converting a NodeList to an array using builtin methods. // converting a NodeList to an array using builtin methods.
try { try {
Array.prototype.slice.call( document.documentElement.childNodes ); Array.prototype.slice.call( document.documentElement.childNodes, 0 );
// Provide a fallback method if it does not work // Provide a fallback method if it does not work
} catch(e){ } catch(e){
......
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