Skip to content
Permalink
Browse files

jquery core: Patch from #2619 applied, making makeArray more flexible…

… and faster; removed hint to ticket from (previously failing) test
  • Loading branch information
jzaefferer committed Apr 24, 2008
1 parent f12d94a commit f8e5fd6fef68d243d22c593584aaf4ee549ed30c
Showing with 8 additions and 7 deletions.
  1. +7 −6 src/core.js
  2. +1 −1 test/unit/core.js
@@ -1123,12 +1123,13 @@ jQuery.extend({
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;
},
@@ -1562,7 +1562,7 @@ test("contents()", function() {
equals( c[0].nodeValue, "hi", "Check node,textnode,comment contents is just the one from span" );
});

test("makeArray(#2619)", function(){
test("$.makeArray", function(){
expect(11);

equals( $.makeArray(document.getElementsByName("PWD")).slice(0,1)[0].name, "PWD", "Pass makeArray a nodelist" );

0 comments on commit f8e5fd6

Please sign in to comment.
You can’t perform that action at this time.