Skip to content

Commit

Permalink
Make toArray an alias for .get(). Closes #3999
Browse files Browse the repository at this point in the history
  • Loading branch information
wycats committed Jul 16, 2009
1 parent 0e2f4a0 commit e124fec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/core.js
Expand Up @@ -122,6 +122,8 @@ jQuery.fn = jQuery.prototype = {
return this.length;
},

toArray: Array.prototype.slice,

// Get the Nth element in the matched element set OR
// Get the whole matched element set as a clean array
get: function( num ) {
Expand Down Expand Up @@ -313,7 +315,7 @@ jQuery.extend({

// args is for internal usage only
each: function( object, callback, args ) {
var name, i = 0,
var name, i = 0,
length = object.length,
isObj = length === undefined || jQuery.isFunction(object);

Expand Down
7 changes: 7 additions & 0 deletions test/unit/core.js
Expand Up @@ -328,6 +328,13 @@ test("get()", function() {
isSet( jQuery("p").get(), q("firstp","ap","sndp","en","sap","first"), "Get All Elements" );
});

test("toArray()", function() {
expect(1);
isSet ( jQuery("p").toArray(),
q("firstp","ap","sndp","en","sap","first"),
"Convert jQuery object to an Array" )
})

test("get(Number)", function() {
expect(1);
equals( jQuery("p").get(0), document.getElementById("firstp"), "Get A Single Element" );
Expand Down

0 comments on commit e124fec

Please sign in to comment.