Skip to content

Commit 0e0b898

Browse files
committed
Core: Warn and fill jQuery.isArray
Fixes jquery#220
1 parent 18618af commit 0e0b898

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

src/core.js

+7
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,11 @@ if ( jQueryVersionSince( "3.3.0" ) ) {
140140
},
141141
"jQuery.isWindow() is deprecated"
142142
);
143+
144+
migrateWarnFunc( jQuery, "isArray",
145+
function( a ) {
146+
return Array.isArray( a );
147+
},
148+
"jQuery.isArray is deprecated; use Array.isArray"
149+
);
143150
}

test/core.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,20 @@ QUnit[ jQueryVersionSince( "3.3.0" ) ? "test" : "skip" ]( "jQuery.type (warn)",
430430

431431
} );
432432

433+
QUnit[ jQueryVersionSince( "3.3.0" ) ? "test" : "skip" ]( "jQuery.isArray", function( assert ) {
434+
assert.expect( 4 );
435+
436+
expectWarning( assert, "isArray", 1, function() {
437+
assert.equal( jQuery.isArray( [] ), true, "empty array" );
438+
assert.equal( jQuery.isArray( "" ), false, "empty string" );
439+
assert.equal( jQuery.isArray( jQuery().toArray() ), true, "toArray" );
440+
} );
441+
442+
} );
443+
433444
TestManager.runIframeTest( "old pre-3.0 jQuery", "core-jquery2.html",
434445
function( assert, jQuery, window, document, log ) {
435446
assert.expect( 1 );
436447

437448
assert.ok( /jQuery 3/.test( log ), "logged: " + log );
438-
} );
449+
} );

warnings.md

+5
Original file line numberDiff line numberDiff line change
@@ -241,3 +241,8 @@ See jQuery-ui [commit](https://github.com/jquery/jquery-ui/commit/c0093b599fcd58
241241
**Cause:** The `jQuery.cssProps` property is a public but undocumented object that allows CSS properties with one name to be mapped into another name. It was used for legacy browsers like IE8 that used non-standard names. This object is no longer used inside jQuery since all supported browsers now use the standard CSS property names.
242242

243243
**Solution:** Remove any uses of `jQuery.cssProps` in application code.
244+
245+
#### JQMIGRATE: jQuery.isArray is deprecated; use Array.isArray
246+
**Cause:** Older versions of JavaScript made it difficult to determine if a particular object was a true Array, so jQuery provided a cross-browser function to do the work. The browsers supported by jQuery 3.0 all provide a standard method for this purpose.
247+
248+
**Solution:** Replace any calls to `jQuery.isArray` with `Array.isArray`.

0 commit comments

Comments
 (0)