Skip to content

Commit 7d2ddb0

Browse files
committed
Core: Use console.info for deprecations without removals.
Also: 1. Group `warnings.md` by this type. 2. Rename `jQuery.migrateWarnings` to `jQuery.migrateMessages`. 3. Rename `jQuery.migrateDeduplicateWarnings` to `jQuery.migrateDeduplicateMessages`. 4. Adding "info" versions of some internal APIs. Fixes gh-472
1 parent 1ac6408 commit 7d2ddb0

24 files changed

+303
-260
lines changed

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ The production build is minified and does not generate console warnings. It will
4848

4949
## Debugging
5050

51-
The development version of the plugin displays warnings in the browser console. Older browsers such as IE9 doesn't support the console interface. No messages will be generated unless you include a debugging library such as [Firebug Lite](https://getfirebug.com/firebuglite) before including the jQuery Migrate plugin. Developers can also inspect the `jQuery.migrateWarnings` array to see what error messages have been generated.
51+
The development version of the plugin displays warnings in the browser console. Older browsers such as IE9 doesn't support the console interface. No messages will be generated unless you include a debugging library such as [Firebug Lite](https://getfirebug.com/firebuglite) before including the jQuery Migrate plugin. Developers can also inspect the `jQuery.migrateMessages` array to see what error messages have been generated.
5252

5353
All warnings generated by this plugin start with the string "JQMIGRATE". A list of the warnings you may see are in [warnings.md](https://github.com/jquery/jquery-migrate/blob/main/warnings.md).
5454

@@ -57,17 +57,17 @@ All warnings generated by this plugin start with the string "JQMIGRATE". A list
5757

5858
This plugin adds some properties to the `jQuery` object that can be used to programmatically control and examine its behavior:
5959

60-
`jQuery.migrateWarnings`: This property is an array of string warning messages that have been generated by the code on the page, in the order they were generated. Messages appear in the array only once, even if the condition has occurred multiple times, unless `jQuery.migrateReset()` is called.
60+
`jQuery.migrateMessages`: This property is an array of string warning messages that have been generated by the code on the page, in the order they were generated. Messages appear in the array only once, even if the condition has occurred multiple times, unless `jQuery.migrateReset()` is called.
6161

62-
`jQuery.migrateMute`: Set this property to `true` to prevent console warnings from being generated in the development version. The `jQuery.migrateWarnings` array is still maintained when this property is set, which allows programmatic inspection without console output.
62+
`jQuery.migrateMute`: Set this property to `true` to prevent console warnings from being generated in the development version. The `jQuery.migrateMessages` array is still maintained when this property is set, which allows programmatic inspection without console output.
6363

6464
`jQuery.migrateTrace`: Set this property to `false` if you want warnings but do not want stack traces to appear on the console.
6565

66-
`jQuery.migrateReset()`: This method clears the `jQuery.migrateWarnings` array and "forgets" the list of messages that have been seen already.
66+
`jQuery.migrateReset()`: This method clears the `jQuery.migrateMessages` array and "forgets" the list of messages that have been seen already.
6767

6868
`jQuery.migrateVersion`: This string property indicates the version of Migrate in use.
6969

70-
`jQuery.migrateDeduplicateWarnings`: By default, Migrate only gives a specific warning once. If you set this property to `false` it will give a warning for every occurrence each time it happens. Note that this can generate a lot of output, for example when a warning occurs in a loop.
70+
`jQuery.migrateDeduplicateMessages`: By default, Migrate only gives a specific warning once. If you set this property to `false` it will give a warning for every occurrence each time it happens. Note that this can generate a lot of output, for example when a warning occurs in a loop.
7171

7272
`jQuery.migrateDisablePatches`: Disables patches by their codes. You can find a code for each patch in square brackets in [warnings.md](https://github.com/jquery/jquery-migrate/blob/main/warnings.md). A limited number of warnings doesn't have codes defined and cannot be disabled. These are mostly setup issues like using an incorrect version of jQuery or loading Migrate multiple times.
7373

eslint.config.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ export default [
9999
QUnit: false,
100100
sinon: false,
101101
url: false,
102-
expectWarning: false,
103-
expectNoWarning: false,
102+
expectMessage: false,
103+
expectNoMessage: false,
104104
compareVersions: false,
105105
jQueryVersionSince: false,
106106
startIframeTest: false,
@@ -132,8 +132,8 @@ export default [
132132
url: true,
133133
compareVersions: true,
134134
jQueryVersionSince: false,
135-
expectWarning: true,
136-
expectNoWarning: true,
135+
expectMessage: true,
136+
expectNoMessage: true,
137137
startIframeTest: true,
138138
TestManager: true
139139
}

src/jquery/ajax.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jQuery.ajaxPrefilter( "+json", function( s, originalSettings, jqXHR ) {
4747

4848
// Handle iff the expected data type is "jsonp" or we have a parameter to set
4949
if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
50-
migrateWarn( "jsonp-promotion", "JSON-to-JSONP auto-promotion is deprecated and removed" );
50+
migrateWarn( "jsonp-promotion", "JSON-to-JSONP auto-promotion is removed" );
5151

5252
// Get callback name, remembering preexisting value associated with it
5353
callbackName = s.jsonpCallback = typeof s.jsonpCallback === "function" ?

src/jquery/attributes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ migratePatchFunc( jQuery.fn, "toggleClass", function( state ) {
9898
return oldToggleClass.apply( this, arguments );
9999
}
100100

101-
migrateWarn( "toggleClass-bool", "jQuery.fn.toggleClass( boolean ) is deprecated and removed" );
101+
migrateWarn( "toggleClass-bool", "jQuery.fn.toggleClass( [ boolean ] ) is removed" );
102102

103103
// Toggle entire class name of each element
104104
return this.each( function() {

src/jquery/core.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { migrateWarnProp, migratePatchAndWarnFunc } from "../main.js";
1+
import { migrateWarnProp, migratePatchAndWarnFunc, migratePatchAndInfoFunc } from "../main.js";
22
import "../disablePatches.js";
33

44
var arr = [],
@@ -14,28 +14,28 @@ var arr = [],
1414
migratePatchAndWarnFunc( jQuery, "parseJSON", function() {
1515
return JSON.parse.apply( null, arguments );
1616
}, "parseJSON",
17-
"jQuery.parseJSON is deprecated and removed; use JSON.parse" );
17+
"jQuery.parseJSON is removed; use JSON.parse" );
1818

19-
migratePatchAndWarnFunc( jQuery, "holdReady", jQuery.holdReady,
20-
"holdReady", "jQuery.holdReady is deprecated" );
19+
migratePatchAndInfoFunc( jQuery, "holdReady", jQuery.holdReady,
20+
"holdReady", "jQuery.holdReady() is deprecated" );
2121

2222
migratePatchAndWarnFunc( jQuery, "unique", jQuery.uniqueSort,
23-
"unique", "jQuery.unique() is deprecated and removed; use jQuery.uniqueSort()" );
23+
"unique", "jQuery.unique() is removed; use jQuery.uniqueSort()" );
2424

2525
migratePatchAndWarnFunc( jQuery, "trim", function( text ) {
2626
return text == null ?
2727
"" :
2828
( text + "" ).replace( rtrim, "$1" );
2929
}, "trim",
30-
"jQuery.trim() is deprecated and removed; use String.prototype.trim" );
30+
"jQuery.trim() is removed; use String.prototype.trim" );
3131

3232
migratePatchAndWarnFunc( jQuery, "nodeName", function( elem, name ) {
3333
return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
3434
}, "nodeName",
35-
"jQuery.nodeName() is deprecated and removed" );
35+
"jQuery.nodeName() is removed" );
3636

3737
migratePatchAndWarnFunc( jQuery, "isArray", Array.isArray, "isArray",
38-
"jQuery.isArray() is deprecated and removed; use Array.isArray()"
38+
"jQuery.isArray() is removed; use Array.isArray()"
3939
);
4040

4141
migratePatchAndWarnFunc( jQuery, "isNumeric",
@@ -52,7 +52,7 @@ migratePatchAndWarnFunc( jQuery, "isNumeric",
5252
// subtraction forces infinities to NaN
5353
!isNaN( obj - parseFloat( obj ) );
5454
}, "isNumeric",
55-
"jQuery.isNumeric() is deprecated and removed"
55+
"jQuery.isNumeric() is removed"
5656
);
5757

5858
// Populate the class2type map
@@ -71,30 +71,30 @@ migratePatchAndWarnFunc( jQuery, "type", function( obj ) {
7171
class2type[ Object.prototype.toString.call( obj ) ] || "object" :
7272
typeof obj;
7373
}, "type",
74-
"jQuery.type() is deprecated abd removed" );
74+
"jQuery.type() is removed" );
7575

7676
migratePatchAndWarnFunc( jQuery, "isFunction", function( obj ) {
7777
return typeof obj === "function";
7878
}, "isFunction",
79-
"jQuery.isFunction() is deprecated and removed" );
79+
"jQuery.isFunction() is removed" );
8080

8181
migratePatchAndWarnFunc( jQuery, "isWindow",
8282
function( obj ) {
8383
return obj != null && obj === obj.window;
8484
}, "isWindow",
85-
"jQuery.isWindow() is deprecated and removed"
85+
"jQuery.isWindow() is removed"
8686
);
8787

8888
// Bind a function to a context, optionally partially applying any
8989
// arguments.
9090
// jQuery.proxy is deprecated to promote standards (specifically Function#bind)
9191
// However, it is not slated for removal any time soon
92-
migratePatchAndWarnFunc( jQuery, "proxy", jQuery.proxy,
92+
migratePatchAndInfoFunc( jQuery, "proxy", jQuery.proxy,
9393
"proxy", "jQuery.proxy() is deprecated" );
9494

9595
migrateWarnProp( jQuery.fn, "push", push, "push",
96-
"jQuery.fn.push() is deprecated and removed; use .add or convert to an array" );
96+
"jQuery.fn.push() is removed; use .add() or convert to an array" );
9797
migrateWarnProp( jQuery.fn, "sort", sort, "sort",
98-
"jQuery.fn.sort() is deprecated and removed; convert to an array before sorting" );
98+
"jQuery.fn.sort() is removed; convert to an array before sorting" );
9999
migrateWarnProp( jQuery.fn, "splice", splice, "splice",
100-
"jQuery.fn.splice() is deprecated and removed; use .slice or .not with .eq" );
100+
"jQuery.fn.splice() is removed; use .slice() or .not() with .eq()" );

src/jquery/css.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var origFnCss, internalCssNumber,
3030
if ( typeof Proxy !== "undefined" ) {
3131
jQuery.cssProps = new Proxy( jQuery.cssProps || {}, {
3232
set: function() {
33-
migrateWarn( "cssProps", "jQuery.cssProps is deprecated and removed" );
33+
migrateWarn( "cssProps", "jQuery.cssProps is removed" );
3434
return Reflect.set.apply( this, arguments );
3535
}
3636
} );
@@ -123,8 +123,8 @@ migratePatchFunc( jQuery.fn, "css", function( name, value ) {
123123
// internal check.
124124
if ( !isAutoPx( camelName ) && !internalCssNumber[ camelName ] ) {
125125
migrateWarn( "css-number",
126-
"Auto-appending 'px' to number-typed values is deprecated and removed " +
127-
"for jQuery.fn.css( \"" + name + "\", value )" );
126+
"Auto-appending 'px' to number-typed values " +
127+
"for jQuery.fn.css( \"" + name + "\", value ) is removed" );
128128
}
129129
}
130130

src/jquery/deferred.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
22
migratePatchFunc,
3-
migratePatchAndWarnFunc,
3+
migratePatchAndInfoFunc,
44
migrateWarn
55
} from "../main.js";
66

@@ -14,9 +14,9 @@ migratePatchFunc( jQuery, "Deferred", function( func ) {
1414
var deferred = oldDeferred(),
1515
promise = deferred.promise();
1616

17-
migratePatchAndWarnFunc( deferred, "pipe", deferred.pipe, "deferred-pipe",
17+
migratePatchAndInfoFunc( deferred, "pipe", deferred.pipe, "deferred-pipe",
1818
"deferred.pipe() is deprecated" );
19-
migratePatchAndWarnFunc( promise, "pipe", promise.pipe, "deferred-pipe",
19+
migratePatchAndInfoFunc( promise, "pipe", promise.pipe, "deferred-pipe",
2020
"deferred.pipe() is deprecated" );
2121

2222
if ( func ) {
@@ -40,8 +40,7 @@ Object.defineProperty( jQuery.Deferred, "getStackHook", {
4040
get: function() {
4141
if ( jQuery.migrateIsPatchEnabled( "deferred-getStackHook" ) ) {
4242
migrateWarn( "deferred-getStackHook",
43-
"jQuery.Deferred.getStackHook is deprecated and removed; " +
44-
"use jQuery.Deferred.getErrorHook" );
43+
"jQuery.Deferred.getStackHook is removed; use jQuery.Deferred.getErrorHook" );
4544
return jQuery.Deferred.getErrorHook;
4645
} else {
4746
return unpatchedGetStackHookValue;
@@ -50,8 +49,7 @@ Object.defineProperty( jQuery.Deferred, "getStackHook", {
5049
set: function( newValue ) {
5150
if ( jQuery.migrateIsPatchEnabled( "deferred-getStackHook" ) ) {
5251
migrateWarn( "deferred-getStackHook",
53-
"jQuery.Deferred.getStackHook is deprecated and removed; " +
54-
"use jQuery.Deferred.getErrorHook" );
52+
"jQuery.Deferred.getStackHook is removed; use jQuery.Deferred.getErrorHook" );
5553
jQuery.Deferred.getErrorHook = newValue;
5654
} else {
5755
unpatchedGetStackHookValue = newValue;

src/jquery/effects.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import "../disablePatches.js";
55
if ( jQuery.fx ) {
66

77
var intervalValue = jQuery.fx.interval,
8-
intervalMsg = "jQuery.fx.interval is deprecated and removed";
8+
intervalMsg = "jQuery.fx.interval is removed";
99

1010
// Don't warn if document is hidden, jQuery uses setTimeout (gh-292)
1111
Object.defineProperty( jQuery.fx, "interval", {

src/jquery/event.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
22
migrateWarn,
3-
migratePatchAndWarnFunc,
3+
migratePatchAndInfoFunc,
44
migratePatchFunc
55
} from "../main.js";
66
import "../disablePatches.js";
@@ -26,18 +26,18 @@ jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
2626
function( _i, name ) {
2727

2828
// Handle event binding
29-
migratePatchAndWarnFunc( jQuery.fn, name, jQuery.fn[ name ], "shorthand-deprecated-v3",
29+
migratePatchAndInfoFunc( jQuery.fn, name, jQuery.fn[ name ], "shorthand-deprecated-v3",
3030
"jQuery.fn." + name + "() event shorthand is deprecated" );
3131
} );
3232

33-
migratePatchAndWarnFunc( jQuery.fn, "bind", jQuery.fn.bind,
33+
migratePatchAndInfoFunc( jQuery.fn, "bind", jQuery.fn.bind,
3434
"pre-on-methods", "jQuery.fn.bind() is deprecated" );
35-
migratePatchAndWarnFunc( jQuery.fn, "unbind", jQuery.fn.unbind,
35+
migratePatchAndInfoFunc( jQuery.fn, "unbind", jQuery.fn.unbind,
3636
"pre-on-methods", "jQuery.fn.unbind() is deprecated" );
37-
migratePatchAndWarnFunc( jQuery.fn, "delegate", jQuery.fn.delegate,
37+
migratePatchAndInfoFunc( jQuery.fn, "delegate", jQuery.fn.delegate,
3838
"pre-on-methods", "jQuery.fn.delegate() is deprecated" );
39-
migratePatchAndWarnFunc( jQuery.fn, "undelegate", jQuery.fn.undelegate,
39+
migratePatchAndInfoFunc( jQuery.fn, "undelegate", jQuery.fn.undelegate,
4040
"pre-on-methods", "jQuery.fn.undelegate() is deprecated" );
4141

42-
migratePatchAndWarnFunc( jQuery.fn, "hover", jQuery.fn.hover,
42+
migratePatchAndInfoFunc( jQuery.fn, "hover", jQuery.fn.hover,
4343
"hover", "jQuery.fn.hover() is deprecated" );

src/jquery/selector.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { migratePatchFunc, migrateWarnProp, migrateWarn } from "../main.js";
1+
import { migratePatchFunc, migrateInfoProp, migrateInfo } from "../main.js";
22

33
// Now jQuery.expr.pseudos is the standard incantation
4-
migrateWarnProp( jQuery.expr, "filters", jQuery.expr.pseudos, "expr-pre-pseudos",
4+
migrateInfoProp( jQuery.expr, "filters", jQuery.expr.pseudos, "expr-pre-pseudos",
55
"jQuery.expr.filters is deprecated; use jQuery.expr.pseudos" );
6-
migrateWarnProp( jQuery.expr, ":", jQuery.expr.pseudos, "expr-pre-pseudos",
6+
migrateInfoProp( jQuery.expr, ":", jQuery.expr.pseudos, "expr-pre-pseudos",
77
"jQuery.expr[':'] is deprecated; use jQuery.expr.pseudos" );
88

99
function markFunction( fn ) {
@@ -33,7 +33,7 @@ migratePatchFunc( jQuery.expr.filter, "PSEUDO", function( pseudo, argument ) {
3333

3434
// But maintain support for old signatures
3535
if ( fn.length > 1 ) {
36-
migrateWarn( "legacy-custom-pseudos",
36+
migrateInfo( "legacy-custom-pseudos",
3737
"Pseudos with multiple arguments are deprecated; " +
3838
"use jQuery.expr.createPseudo()" );
3939
args = [ pseudo, pseudo, "", argument ];
@@ -60,7 +60,7 @@ if ( typeof Proxy !== "undefined" ) {
6060
jQuery.expr[ api ] = new Proxy( jQuery.expr[ api ], {
6161
set: function( _target, _prop, fn ) {
6262
if ( typeof fn === "function" && !fn[ jQuery.expando ] && fn.length > 1 ) {
63-
migrateWarn( "legacy-custom-pseudos",
63+
migrateInfo( "legacy-custom-pseudos",
6464
"Pseudos with multiple arguments are deprecated; " +
6565
"use jQuery.expr.createPseudo()" );
6666
}

0 commit comments

Comments
 (0)