Skip to content

Commit 95fd84d

Browse files
committed
Core: Remove support for jQuery 4.x
1 parent 6c02753 commit 95fd84d

27 files changed

+351
-722
lines changed

.github/workflows/browser-tests.yml

-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ jobs:
4747
npm run pretest
4848
npm run test:unit -- -b ${{ matrix.BROWSER }} -h \
4949
--jquery-migrate ${{ matrix.MIGRATE_VERSION }} \
50-
--jquery git --jquery git.min --jquery git.slim --jquery git.slim.min \
5150
--jquery 3.x-git --jquery 3.x-git.min --jquery 3.x-git.slim --jquery 3.x-git.slim.min \
5251
--jquery 3.7.1 --jquery 3.7.1.slim \
5352
--jquery 3.6.4 --jquery 3.5.1 --jquery 3.4.1 \
@@ -84,7 +83,6 @@ jobs:
8483
run: |
8584
npm run test:ie -- ^
8685
--jquery-migrate ${{ env.MIGRATE_VERSION }} ^
87-
--jquery git --jquery git.min --jquery git.slim --jquery git.slim.min ^
8886
--jquery 3.x-git --jquery 3.x-git.min --jquery 3.x-git.slim --jquery 3.x-git.slim.min ^
8987
--jquery 3.7.1 --jquery 3.7.1.slim ^
9088
--jquery 3.6.4 --jquery 3.5.1 --jquery 3.4.1 ^
@@ -120,7 +118,6 @@ jobs:
120118
run: |
121119
npm run test:safari -- \
122120
--jquery-migrate ${{ env.MIGRATE_VERSION }} \
123-
--jquery git --jquery git.min --jquery git.slim --jquery git.slim.min \
124121
--jquery 3.x-git --jquery 3.x-git.min --jquery 3.x-git.slim --jquery 3.x-git.slim.min \
125122
--jquery 3.7.1 --jquery 3.7.1.slim \
126123
--jquery 3.6.4 --jquery 3.5.1 --jquery 3.4.1 \

.github/workflows/browserstack-git.yml

-71
This file was deleted.

.github/workflows/browserstack-3.x.yml renamed to .github/workflows/browserstack.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Browserstack (Core 3.x)
1+
name: Browserstack
22

33
on:
44
push:

.github/workflows/filestash.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,5 @@ jobs:
4747
4848
- name: Upload to Filestash
4949
run: |
50-
rsync dist/jquery-migrate.js filestash@"${{ secrets.FILESTASH_SERVER }}":jquery-migrate-git.js
51-
rsync dist/jquery-migrate.min.js filestash@"${{ secrets.FILESTASH_SERVER }}":jquery-migrate-git.min.js
50+
rsync dist/jquery-migrate.js filestash@"${{ secrets.FILESTASH_SERVER }}":jquery-migrate-3.x-git.js
51+
rsync dist/jquery-migrate.min.js filestash@"${{ secrets.FILESTASH_SERVER }}":jquery-migrate-3.x-git.min.js

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Make sure you have reproduced the bug with all browser extensions and add-ons di
4747

4848
### Try the latest version of jQuery Migrate
4949

50-
Bugs in old versions of jQuery Migrate may have already been fixed. In order to avoid reporting known issues, make sure you are always testing against the [latest build](https://releases.jquery.com/git/jquery-migrate-git.js). We cannot fix bugs in older released files, if a bug has been fixed in a subsequent version of jQuery Migrate the site should upgrade.
50+
Bugs in old versions of jQuery Migrate may have already been fixed. In order to avoid reporting known issues, make sure you are always testing against the [latest build](https://releases.jquery.com/git/jquery-migrate-3.x-git.js). We cannot fix bugs in older released files, if a bug has been fixed in a subsequent version of jQuery Migrate the site should upgrade.
5151

5252
### Simplify the test case
5353

README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ That way you can spot and fix what otherwise would have been errors, until you n
1111

1212
The following table indicates which jQuery Migrate versions can be used with which jQuery versions:
1313

14-
| jQuery version | jQuery Migrate version |
15-
|----------------|-------------------------|
16-
| 1.x | 1.x |
17-
| 2.x | 1.x |
18-
| 3.x | 3.x / 4.x<sup>[1]</sup> |
19-
| 4.x | 3.x / 4.x<sup>[1]</sup> |
14+
| jQuery version | jQuery Migrate version |
15+
|----------------|------------------------|
16+
| 1.x | 1.x |
17+
| 2.x | 1.x |
18+
| 3.x | 3.x |
19+
| 4.x | 4.x |
2020

21-
[1] NOTE: jQuery Migrate 4.x only supports the same browser as jQuery 4.x does. If you need to support Edge Legacy, Internet Explorer 9-10 or iOS 7+ (and not just 3 latest versions), use jQuery Migrate 3.x.
21+
Each jQuery Migrate version supports the same browsers that the jQuery version used with it.
2222

2323
## Usage
2424

@@ -40,7 +40,7 @@ The production build is minified and does not generate console warnings. It will
4040
| Debugging enabled | <p align="center">✓</p> | |
4141
| Minified | | <p align="center">✓</p> |
4242
| Latest release (*may be hotlinked if desired*) | [jquery-migrate-3.5.2.js](https://code.jquery.com/jquery-migrate-3.5.2.js) | [jquery-migrate-3.5.2.min.js](https://code.jquery.com/jquery-migrate-3.5.2.min.js) |
43-
| \* Latest work-in-progress build | [jquery-migrate-git.js](https://releases.jquery.com/git/jquery-migrate-git.js) | [jquery-migrate-git.min.js](https://releases.jquery.com/git/jquery-migrate-git.min.js) |
43+
| \* Latest work-in-progress build | [jquery-migrate-3.x-git.js](https://releases.jquery.com/git/jquery-migrate-3.x-git.js) | [jquery-migrate-3.x-git.min.js](https://releases.jquery.com/git/jquery-migrate-3.x-git.min.js) |
4444

4545

4646
\* **Work-in-progress build:** Although this file represents the most recent updates to the plugin, it may not have been thoroughly tested. We do not recommend using this file on production sites since it may be unstable; use the released production version instead.

src/jquery/ajax.js

+17-116
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { jQueryVersionSince } from "../compareVersions.js";
21
import { migrateWarn, migratePatchAndWarnFunc, migratePatchFunc } from "../main.js";
32

43
// Support jQuery slim which excludes the ajax module
@@ -8,8 +7,7 @@ var oldAjax = jQuery.ajax,
87
oldCallbacks = [],
98
guid = "migrate-" + Date.now(),
109
origJsonpCallback = jQuery.ajaxSettings.jsonpCallback,
11-
rjsonp = /(=)\?(?=&|$)|\?\?/,
12-
rquery = /\?/;
10+
rjsonp = /(=)\?(?=&|$)|\?\?/;
1311

1412
migratePatchFunc( jQuery, "ajax", function() {
1513
var jQXHR = oldAjax.apply( this, arguments );
@@ -45,120 +43,23 @@ jQuery.ajaxSetup( {
4543
// Register this prefilter before the jQuery one. Otherwise, a promoted
4644
// request is transformed into one with the script dataType, and we can't
4745
// catch it anymore.
48-
if ( jQueryVersionSince( "4.0.0" ) ) {
49-
50-
// Code mostly from:
51-
// https://github.com/jquery/jquery/blob/fa0058af426c4e482059214c29c29f004254d9a1/src/ajax/jsonp.js#L20-L97
52-
jQuery.ajaxPrefilter( "+json", function( s, originalSettings, jqXHR ) {
53-
54-
if ( !jQuery.migrateIsPatchEnabled( "jsonp-promotion" ) ) {
55-
return;
56-
}
57-
58-
var callbackName, overwritten, responseContainer,
59-
jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
60-
"url" :
61-
typeof s.data === "string" &&
62-
( s.contentType || "" )
63-
.indexOf( "application/x-www-form-urlencoded" ) === 0 &&
64-
rjsonp.test( s.data ) && "data"
65-
);
66-
67-
// Handle iff the expected data type is "jsonp" or we have a parameter to set
68-
if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
69-
migrateWarn( "jsonp-promotion", "JSON-to-JSONP auto-promotion is deprecated" );
70-
71-
// Get callback name, remembering preexisting value associated with it
72-
callbackName = s.jsonpCallback = typeof s.jsonpCallback === "function" ?
73-
s.jsonpCallback() :
74-
s.jsonpCallback;
75-
76-
// Insert callback into url or form data
77-
if ( jsonProp ) {
78-
s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
79-
} else if ( s.jsonp !== false ) {
80-
s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
81-
}
82-
83-
// Use data converter to retrieve json after script execution
84-
s.converters[ "script json" ] = function() {
85-
if ( !responseContainer ) {
86-
jQuery.error( callbackName + " was not called" );
87-
}
88-
return responseContainer[ 0 ];
89-
};
90-
91-
// Force json dataType
92-
s.dataTypes[ 0 ] = "json";
93-
94-
// Install callback
95-
overwritten = window[ callbackName ];
96-
window[ callbackName ] = function() {
97-
responseContainer = arguments;
98-
};
99-
100-
// Clean-up function (fires after converters)
101-
jqXHR.always( function() {
102-
103-
// If previous value didn't exist - remove it
104-
if ( overwritten === undefined ) {
105-
jQuery( window ).removeProp( callbackName );
106-
107-
// Otherwise restore preexisting value
108-
} else {
109-
window[ callbackName ] = overwritten;
110-
}
111-
112-
// Save back as free
113-
if ( s[ callbackName ] ) {
114-
115-
// Make sure that re-using the options doesn't screw things around
116-
s.jsonpCallback = originalSettings.jsonpCallback;
117-
118-
// Save the callback name for future use
119-
oldCallbacks.push( callbackName );
120-
}
121-
122-
// Call if it was a function and we have a response
123-
if ( responseContainer && typeof overwritten === "function" ) {
124-
overwritten( responseContainer[ 0 ] );
125-
}
126-
127-
responseContainer = overwritten = undefined;
128-
} );
129-
130-
// Delegate to script
131-
return "script";
132-
}
133-
} );
134-
} else {
135-
136-
// jQuery <4 already contains this prefixer; don't duplicate the whole logic,
137-
// but only enough to know when to warn.
138-
jQuery.ajaxPrefilter( "+json", function( s ) {
139-
140-
if ( !jQuery.migrateIsPatchEnabled( "jsonp-promotion" ) ) {
141-
return;
142-
}
143-
144-
// Warn if JSON-to-JSONP auto-promotion happens.
145-
if ( s.jsonp !== false && ( rjsonp.test( s.url ) ||
146-
typeof s.data === "string" &&
147-
( s.contentType || "" )
148-
.indexOf( "application/x-www-form-urlencoded" ) === 0 &&
149-
rjsonp.test( s.data )
150-
) ) {
151-
migrateWarn( "jsonp-promotion", "JSON-to-JSONP auto-promotion is deprecated" );
152-
}
153-
} );
154-
}
46+
// jQuery <4 already contains this prefixer; don't duplicate the whole logic,
47+
// but only enough to know when to warn.
48+
jQuery.ajaxPrefilter( "+json", function( s ) {
15549

50+
if ( !jQuery.migrateIsPatchEnabled( "jsonp-promotion" ) ) {
51+
return;
52+
}
15653

157-
// Don't trigger the above logic in jQuery >=4 by default as the JSON-to-JSONP
158-
// auto-promotion behavior is gone in jQuery 4.0 and as it has security implications,
159-
// we don't want to restore the legacy behavior by default.
160-
if ( jQueryVersionSince( "4.0.0" ) ) {
161-
jQuery.migrateDisablePatches( "jsonp-promotion" );
162-
}
54+
// Warn if JSON-to-JSONP auto-promotion happens.
55+
if ( s.jsonp !== false && ( rjsonp.test( s.url ) ||
56+
typeof s.data === "string" &&
57+
( s.contentType || "" )
58+
.indexOf( "application/x-www-form-urlencoded" ) === 0 &&
59+
rjsonp.test( s.data )
60+
) ) {
61+
migrateWarn( "jsonp-promotion", "JSON-to-JSONP auto-promotion is deprecated" );
62+
}
63+
} );
16364

16465
}

0 commit comments

Comments
 (0)