Side navigation
Ticket #2619: makeArray.diff
File makeArray.diff, 0.7 KB (added by flesler, March 29, 2008 08:07PM UTC)
Index: src/core.js
===================================================================
--- src/core.js (revision 5143)
+++ src/core.js (working copy)
@@ -1120,12 +1120,13 @@
makeArray: function( array ) {
var ret = [];
- // Need to use typeof to fight Safari childNodes crashes
- if ( array.constructor != Array )
- for ( var i = 0, length = array.length; i < length; i++ )
- ret.push( array[ i ] );
- else
- ret = array.slice( 0 );
+ if( array != undefined )
+ //strings and functions also have 'length'
+ if( array.length != undefined && !array.split && !array.call )
+ for( var i = array.length; i; )
+ ret[--i] = array[i];
+ else
+ ret[0] = array;
return ret;
},
Download in other formats:
Original Format
File makeArray.diff, 0.7 KB (added by flesler, March 29, 2008 08:07PM UTC)
Index: src/core.js
===================================================================
--- src/core.js (revision 5143)
+++ src/core.js (working copy)
@@ -1120,12 +1120,13 @@
makeArray: function( array ) {
var ret = [];
- // Need to use typeof to fight Safari childNodes crashes
- if ( array.constructor != Array )
- for ( var i = 0, length = array.length; i < length; i++ )
- ret.push( array[ i ] );
- else
- ret = array.slice( 0 );
+ if( array != undefined )
+ //strings and functions also have 'length'
+ if( array.length != undefined && !array.split && !array.call )
+ for( var i = array.length; i; )
+ ret[--i] = array[i];
+ else
+ ret[0] = array;
return ret;
},