Skip to content

Commit 415e26e

Browse files
committed
Core: Remove patches for breaking changes in jQuery 3.0.0 or older
The `self-closed-tags` patch remains, despite being a breaking change in jQuery 3.5.0, not 4.0.0. There are a few reasons for that: 1. It's an exception that a breaking change arrived in a non-major version bump. Some people may be upgrading from jQuery 3.4.0 or older and it's good to make it work for them. 2. The patch is disabled by default, so the concern of people on newer jQuery 3.x upgrading to jQuery 4.x with Migrate 4.x getting patches restoring behavior from an version older than the pre-upgrade one does not exist. 3. This was a pretty big break, it may help people update if we still support it. # Conflicts: # src/jquery/attributes.js # test/unit/jquery/attributes.js # warnings.md
1 parent 8795bdc commit 415e26e

32 files changed

+84
-1212
lines changed

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"title": "jQuery Migrate",
44
"description": "Migrate older jQuery code to jQuery 3.0+",
55
"main": "dist/jquery-migrate.js",
6-
"version": "3.5.3-pre",
6+
"version": "4.0.0-pre",
77
"type": "module",
88
"homepage": "https://github.com/jquery/jquery-migrate",
99
"author": {

src/jquery/ajax.js

+3-20
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,14 @@
1-
import { migrateWarn, migratePatchAndWarnFunc, migratePatchFunc } from "../main.js";
1+
import { migrateWarn } from "../main.js";
22

33
// Support jQuery slim which excludes the ajax module
44
if ( jQuery.ajax ) {
55

6-
var oldAjax = jQuery.ajax,
7-
oldCallbacks = [],
6+
var oldCallbacks = [],
87
guid = "migrate-" + Date.now(),
98
origJsonpCallback = jQuery.ajaxSettings.jsonpCallback,
109
rjsonp = /(=)\?(?=&|$)|\?\?/,
1110
rquery = /\?/;
1211

13-
migratePatchFunc( jQuery, "ajax", function() {
14-
var jQXHR = oldAjax.apply( this, arguments );
15-
16-
// Be sure we got a jQXHR (e.g., not sync)
17-
if ( jQXHR.promise ) {
18-
migratePatchAndWarnFunc( jQXHR, "success", jQXHR.done, "jqXHR-methods",
19-
"jQXHR.success is deprecated and removed" );
20-
migratePatchAndWarnFunc( jQXHR, "error", jQXHR.fail, "jqXHR-methods",
21-
"jQXHR.error is deprecated and removed" );
22-
migratePatchAndWarnFunc( jQXHR, "complete", jQXHR.always, "jqXHR-methods",
23-
"jQXHR.complete is deprecated and removed" );
24-
}
25-
26-
return jQXHR;
27-
}, "jqXHR-methods" );
28-
2912
jQuery.ajaxSetup( {
3013
jsonpCallback: function() {
3114

@@ -64,7 +47,7 @@ jQuery.ajaxPrefilter( "+json", function( s, originalSettings, jqXHR ) {
6447

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

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

src/jquery/attributes.js

+2-32
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import { migratePatchFunc, migrateWarn } from "../main.js";
22

3-
var oldRemoveAttr = jQuery.fn.removeAttr,
4-
oldJQueryAttr = jQuery.attr,
3+
var oldJQueryAttr = jQuery.attr,
54
oldToggleClass = jQuery.fn.toggleClass,
65
booleans = "checked|selected|async|autofocus|autoplay|controls|defer|" +
76
"disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
87
rbooleans = new RegExp( "^(?:" + booleans + ")$", "i" ),
9-
rmatchNonSpace = /\S+/g,
108

119
// Some formerly boolean attributes gained new values with special meaning.
1210
// Skip the old boolean attr logic for those values.
@@ -92,34 +90,6 @@ migratePatchFunc( jQuery, "attr", function( elem, name, value ) {
9290
return oldJQueryAttr.apply( this, arguments );
9391
}, "attr-false" );
9492

95-
migratePatchFunc( jQuery.fn, "removeAttr", function( name ) {
96-
var self = this,
97-
patchNeeded = false;
98-
99-
jQuery.each( name.match( rmatchNonSpace ), function( _i, attr ) {
100-
if ( rbooleans.test( attr ) ) {
101-
102-
// Only warn if at least a single node had the property set to
103-
// something else than `false`. Otherwise, this Migrate patch
104-
// doesn't influence the behavior and there's no need to set or warn.
105-
self.each( function() {
106-
if ( jQuery( this ).prop( attr ) !== false ) {
107-
patchNeeded = true;
108-
return false;
109-
}
110-
} );
111-
}
112-
113-
if ( patchNeeded ) {
114-
migrateWarn( "removeAttr-bool",
115-
"jQuery.fn.removeAttr no longer sets boolean properties: " + attr );
116-
self.prop( attr, false );
117-
}
118-
} );
119-
120-
return oldRemoveAttr.apply( this, arguments );
121-
}, "removeAttr-bool" );
122-
12393
migratePatchFunc( jQuery.fn, "toggleClass", function( state ) {
12494

12595
// Only deprecating no-args or single boolean arg
@@ -128,7 +98,7 @@ migratePatchFunc( jQuery.fn, "toggleClass", function( state ) {
12898
return oldToggleClass.apply( this, arguments );
12999
}
130100

131-
migrateWarn( "toggleClass-bool", "jQuery.fn.toggleClass( boolean ) is deprecated" );
101+
migrateWarn( "toggleClass-bool", "jQuery.fn.toggleClass( boolean ) is deprecated and removed" );
132102

133103
// Toggle entire class name of each element
134104
return this.each( function() {

src/jquery/core.js

+9-15
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,31 @@ var arr = [],
1212
// to avoid O(N^2) behavior when the engine would try matching "\s+$" at each space position.
1313
rtrim = /^[\s\uFEFF\xA0]+|([^\s\uFEFF\xA0])[\s\uFEFF\xA0]+$/g;
1414

15-
// The number of elements contained in the matched element set
16-
migratePatchAndWarnFunc( jQuery.fn, "size", function() {
17-
return this.length;
18-
}, "size",
19-
"jQuery.fn.size() is deprecated and removed; use the .length property" );
20-
2115
migratePatchAndWarnFunc( jQuery, "parseJSON", function() {
2216
return JSON.parse.apply( null, arguments );
2317
}, "parseJSON",
24-
"jQuery.parseJSON is deprecated; use JSON.parse" );
18+
"jQuery.parseJSON is deprecated and removed; use JSON.parse" );
2519

2620
migratePatchAndWarnFunc( jQuery, "holdReady", jQuery.holdReady,
2721
"holdReady", "jQuery.holdReady is deprecated" );
2822

2923
migratePatchAndWarnFunc( jQuery, "unique", jQuery.uniqueSort,
30-
"unique", "jQuery.unique is deprecated; use jQuery.uniqueSort" );
24+
"unique", "jQuery.unique() is deprecated and removed; use jQuery.uniqueSort()" );
3125

3226
migratePatchAndWarnFunc( jQuery, "trim", function( text ) {
3327
return text == null ?
3428
"" :
3529
( text + "" ).replace( rtrim, "$1" );
3630
}, "trim",
37-
"jQuery.trim is deprecated; use String.prototype.trim" );
31+
"jQuery.trim() is deprecated and removed; use String.prototype.trim" );
3832

3933
migratePatchAndWarnFunc( jQuery, "nodeName", function( elem, name ) {
4034
return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
4135
}, "nodeName",
42-
"jQuery.nodeName is deprecated" );
36+
"jQuery.nodeName() is deprecated and removed" );
4337

4438
migratePatchAndWarnFunc( jQuery, "isArray", Array.isArray, "isArray",
45-
"jQuery.isArray is deprecated; use Array.isArray"
39+
"jQuery.isArray() is deprecated and removed; use Array.isArray()"
4640
);
4741

4842
migratePatchAndWarnFunc( jQuery, "isNumeric",
@@ -59,7 +53,7 @@ migratePatchAndWarnFunc( jQuery, "isNumeric",
5953
// subtraction forces infinities to NaN
6054
!isNaN( obj - parseFloat( obj ) );
6155
}, "isNumeric",
62-
"jQuery.isNumeric() is deprecated"
56+
"jQuery.isNumeric() is deprecated and removed"
6357
);
6458

6559
// Populate the class2type map
@@ -78,18 +72,18 @@ migratePatchAndWarnFunc( jQuery, "type", function( obj ) {
7872
class2type[ Object.prototype.toString.call( obj ) ] || "object" :
7973
typeof obj;
8074
}, "type",
81-
"jQuery.type is deprecated" );
75+
"jQuery.type() is deprecated abd removed" );
8276

8377
migratePatchAndWarnFunc( jQuery, "isFunction", function( obj ) {
8478
return typeof obj === "function";
8579
}, "isFunction",
86-
"jQuery.isFunction() is deprecated" );
80+
"jQuery.isFunction() is deprecated and removed" );
8781

8882
migratePatchAndWarnFunc( jQuery, "isWindow",
8983
function( obj ) {
9084
return obj != null && obj === obj.window;
9185
}, "isWindow",
92-
"jQuery.isWindow() is deprecated"
86+
"jQuery.isWindow() is deprecated and removed"
9387
);
9488

9589
// Bind a function to a context, optionally partially applying any

src/jquery/css.js

+3-46
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { migrateWarn, migratePatchFunc } from "../main.js";
22
import { camelCase } from "../utils.js";
33

44
var origFnCss, internalCssNumber,
5-
internalSwapCall = false,
65
ralphaStart = /^[a-z]/,
76

87
// The regex visualized:
@@ -28,52 +27,10 @@ var origFnCss, internalCssNumber,
2827
// \ Max / \ Height /
2928
rautoPx = /^(?:Border(?:Top|Right|Bottom|Left)?(?:Width|)|(?:Margin|Padding)?(?:Top|Right|Bottom|Left)?|(?:Min|Max)?(?:Width|Height))$/;
3029

31-
// If this version of jQuery has .swap(), don't false-alarm on internal uses
32-
if ( jQuery.swap ) {
33-
jQuery.each( [ "height", "width", "reliableMarginRight" ], function( _, name ) {
34-
var oldHook = jQuery.cssHooks[ name ] && jQuery.cssHooks[ name ].get;
35-
36-
if ( oldHook ) {
37-
jQuery.cssHooks[ name ].get = function() {
38-
var ret;
39-
40-
internalSwapCall = true;
41-
ret = oldHook.apply( this, arguments );
42-
internalSwapCall = false;
43-
return ret;
44-
};
45-
}
46-
} );
47-
}
48-
49-
migratePatchFunc( jQuery, "swap", function( elem, options, callback, args ) {
50-
var ret, name,
51-
old = {};
52-
53-
if ( !internalSwapCall ) {
54-
migrateWarn( "swap", "jQuery.swap() is undocumented and deprecated" );
55-
}
56-
57-
// Remember the old values, and insert the new ones
58-
for ( name in options ) {
59-
old[ name ] = elem.style[ name ];
60-
elem.style[ name ] = options[ name ];
61-
}
62-
63-
ret = callback.apply( elem, args || [] );
64-
65-
// Revert the old values
66-
for ( name in options ) {
67-
elem.style[ name ] = old[ name ];
68-
}
69-
70-
return ret;
71-
}, "swap" );
72-
7330
if ( typeof Proxy !== "undefined" ) {
7431
jQuery.cssProps = new Proxy( jQuery.cssProps || {}, {
7532
set: function() {
76-
migrateWarn( "cssProps", "jQuery.cssProps is deprecated" );
33+
migrateWarn( "cssProps", "jQuery.cssProps is deprecated and removed" );
7734
return Reflect.set.apply( this, arguments );
7835
}
7936
} );
@@ -166,8 +123,8 @@ migratePatchFunc( jQuery.fn, "css", function( name, value ) {
166123
// internal check.
167124
if ( !isAutoPx( camelName ) && !internalCssNumber[ camelName ] ) {
168125
migrateWarn( "css-number",
169-
"Number-typed values are deprecated for jQuery.fn.css( \"" +
170-
name + "\", value )" );
126+
"Auto-appending 'px' to number-typed values is deprecated and removed " +
127+
"for jQuery.fn.css( \"" + name + "\", value )" );
171128
}
172129
}
173130

src/jquery/data.js

-44
This file was deleted.

src/jquery/deferred.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Object.defineProperty( jQuery.Deferred, "getStackHook", {
7979
get: function() {
8080
if ( jQuery.migrateIsPatchEnabled( "deferred-getStackHook" ) ) {
8181
migrateWarn( "deferred-getStackHook",
82-
"jQuery.Deferred.getStackHook is deprecated; " +
82+
"jQuery.Deferred.getStackHook is deprecated and removed; " +
8383
"use jQuery.Deferred.getErrorHook" );
8484
return jQuery.Deferred.getErrorHook;
8585
} else {
@@ -89,7 +89,7 @@ Object.defineProperty( jQuery.Deferred, "getStackHook", {
8989
set: function( newValue ) {
9090
if ( jQuery.migrateIsPatchEnabled( "deferred-getStackHook" ) ) {
9191
migrateWarn( "deferred-getStackHook",
92-
"jQuery.Deferred.getStackHook is deprecated; " +
92+
"jQuery.Deferred.getStackHook is deprecated and removed; " +
9393
"use jQuery.Deferred.getErrorHook" );
9494
jQuery.Deferred.getErrorHook = newValue;
9595
} else {

src/jquery/effects.js

+3-22
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,11 @@
1-
import { migratePatchFunc, migrateWarn } from "../main.js";
1+
import { migrateWarn } from "../main.js";
22
import "../disablePatches.js";
33

44
// Support jQuery slim which excludes the effects module
55
if ( jQuery.fx ) {
66

7-
var intervalValue, intervalMsg,
8-
oldTweenRun = jQuery.Tween.prototype.run,
9-
linearEasing = function( pct ) {
10-
return pct;
11-
};
12-
13-
migratePatchFunc( jQuery.Tween.prototype, "run", function( ) {
14-
if ( jQuery.easing[ this.easing ].length > 1 ) {
15-
migrateWarn(
16-
"easing-one-arg",
17-
"'jQuery.easing." + this.easing.toString() + "' should use only one argument"
18-
);
19-
20-
jQuery.easing[ this.easing ] = linearEasing;
21-
}
22-
23-
oldTweenRun.apply( this, arguments );
24-
}, "easing-one-arg" );
25-
26-
intervalValue = jQuery.fx.interval;
27-
intervalMsg = "jQuery.fx.interval is deprecated";
7+
var intervalValue = jQuery.fx.interval,
8+
intervalMsg = "jQuery.fx.interval is deprecated and removed";
289

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

0 commit comments

Comments
 (0)