🌐 AI搜索 & 代理 主页
Skip to content

Commit e124fec

Browse files
committed
Make toArray an alias for .get(). Closes #3999
1 parent 0e2f4a0 commit e124fec

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/core.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ jQuery.fn = jQuery.prototype = {
122122
return this.length;
123123
},
124124

125+
toArray: Array.prototype.slice,
126+
125127
// Get the Nth element in the matched element set OR
126128
// Get the whole matched element set as a clean array
127129
get: function( num ) {
@@ -313,7 +315,7 @@ jQuery.extend({
313315

314316
// args is for internal usage only
315317
each: function( object, callback, args ) {
316-
var name, i = 0,
318+
var name, i = 0,
317319
length = object.length,
318320
isObj = length === undefined || jQuery.isFunction(object);
319321

test/unit/core.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,13 @@ test("get()", function() {
328328
isSet( jQuery("p").get(), q("firstp","ap","sndp","en","sap","first"), "Get All Elements" );
329329
});
330330

331+
test("toArray()", function() {
332+
expect(1);
333+
isSet ( jQuery("p").toArray(),
334+
q("firstp","ap","sndp","en","sap","first"),
335+
"Convert jQuery object to an Array" )
336+
})
337+
331338
test("get(Number)", function() {
332339
expect(1);
333340
equals( jQuery("p").get(0), document.getElementById("firstp"), "Get A Single Element" );

0 commit comments

Comments
 (0)