diff --git a/.github/workflows/browserstack-3.x.yml b/.github/workflows/browserstack-3.x.yml
deleted file mode 100644
index a9748638..00000000
--- a/.github/workflows/browserstack-3.x.yml
+++ /dev/null
@@ -1,84 +0,0 @@
-name: Browserstack (Core 3.x)
-
-on:
- push:
- branches:
- - main
- # Once a week every Tuesday
- schedule:
- - cron: "12 2 * * 2"
-
-jobs:
- test:
- runs-on: ubuntu-latest
- environment: browserstack
- env:
- BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
- BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
- NODE_VERSION: 22.x
- name: ${{ matrix.BROWSER }}
- concurrency:
- group: ${{ matrix.BROWSER }} - ${{ github.sha }}
- timeout-minutes: 30
- strategy:
- fail-fast: false
- matrix:
- BROWSER:
- - 'IE_11'
- - 'IE_10'
- - 'IE_9'
- - 'Safari_latest'
- - 'Safari_latest-1'
- - 'Chrome_latest'
- - 'Chrome_latest-1'
- - 'Opera_latest'
- - 'Edge_latest'
- - 'Edge_latest-1'
- - 'Edge_18'
- - 'Firefox_latest'
- - 'Firefox_latest-1'
- - 'Firefox_115'
- - 'Firefox_102'
- - 'Firefox_91'
- - 'Firefox_78'
- - 'Firefox_60'
- - 'Firefox_48'
- - '__iOS_18'
- - '__iOS_17'
- - '__iOS_16'
- - '__iOS_15'
- - '__iOS_14'
- - '__iOS_13'
- - '__iOS_12'
- - '__iOS_11'
- - '__iOS_10'
- - '__iOS_9'
- - '__iOS_8'
- steps:
- - name: Checkout
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
-
- - name: Use Node.js ${{ env.NODE_VERSION }}
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
- with:
- node-version: ${{ env.NODE_VERSION }}
-
- - name: Cache
- uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
- with:
- path: ~/.npm
- key: ${{ runner.os }}-node-${{ env.NODE_VERSION }}-npm-lock-${{ hashFiles('**/package-lock.json') }}
- restore-keys: |
- ${{ runner.os }}-node-${{ env.NODE_VERSION }}-npm-lock-
-
- - name: Install dependencies
- run: npm install
-
- - name: Pretest script
- run: npm run pretest
-
- - name: Test
- run: |
- npm run test:unit -- -v -c jtr-3.x.yml \
- --browserstack "${{ matrix.BROWSER }}" \
- --run-id ${{ github.run_id }} \
diff --git a/.github/workflows/browserstack-git.yml b/.github/workflows/browserstack.yml
similarity index 95%
rename from .github/workflows/browserstack-git.yml
rename to .github/workflows/browserstack.yml
index 40247557..f37103f9 100644
--- a/.github/workflows/browserstack-git.yml
+++ b/.github/workflows/browserstack.yml
@@ -1,4 +1,4 @@
-name: Browserstack (Core git)
+name: Browserstack
on:
push:
@@ -63,6 +63,6 @@ jobs:
- name: Test
run: |
- npm run test:unit -- -v -c jtr-git.yml \
+ npm run test:unit -- -v -c jtr-ci.yml \
--browserstack "${{ matrix.BROWSER }}" \
--run-id ${{ github.run_id }} \
diff --git a/README.md b/README.md
index 5512c8e4..33ce23ab 100644
--- a/README.md
+++ b/README.md
@@ -11,14 +11,14 @@ That way you can spot and fix what otherwise would have been errors, until you n
The following table indicates which jQuery Migrate versions can be used with which jQuery versions:
-| jQuery version | jQuery Migrate version |
-|----------------|-------------------------|
-| 1.x | 1.x |
-| 2.x | 1.x |
-| 3.x | 3.x / 4.x[1] |
-| 4.x | 3.x / 4.x[1] |
+| jQuery version | jQuery Migrate version |
+|----------------|------------------------|
+| 1.x | 1.x |
+| 2.x | 1.x |
+| 3.x | 3.x |
+| 4.x | 4.x |
-[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.
+Each jQuery Migrate version supports the same browsers that the jQuery version used with it. See the [jQuery Browser Support page](https://jquery.com/browser-support/) for more information.
## Usage
@@ -48,7 +48,7 @@ The production build is minified and does not generate console warnings. It will
## Debugging
-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.
+The development version of the plugin displays warnings in the browser console. Developers can also inspect the `jQuery.migrateMessages` array to see what error messages have been generated.
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).
@@ -57,17 +57,17 @@ All warnings generated by this plugin start with the string "JQMIGRATE". A list
This plugin adds some properties to the `jQuery` object that can be used to programmatically control and examine its behavior:
-`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.
+`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.
-`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.
+`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.
`jQuery.migrateTrace`: Set this property to `false` if you want warnings but do not want stack traces to appear on the console.
-`jQuery.migrateReset()`: This method clears the `jQuery.migrateWarnings` array and "forgets" the list of messages that have been seen already.
+`jQuery.migrateReset()`: This method clears the `jQuery.migrateMessages` array and "forgets" the list of messages that have been seen already.
`jQuery.migrateVersion`: This string property indicates the version of Migrate in use.
-`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.
+`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.
`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.
diff --git a/build/tasks/minify.js b/build/tasks/minify.js
index 5f55d27a..6f886063 100644
--- a/build/tasks/minify.js
+++ b/build/tasks/minify.js
@@ -34,19 +34,10 @@ export async function minify( { dir, filename, version } ) {
{
compress: {
hoist_funs: false,
- loops: false,
-
- // Support: IE <11
- // typeofs transformation is unsafe for IE9-10
- // See https://github.com/mishoo/UglifyJS2/issues/2198
- typeofs: false
+ loops: false
},
output: {
ascii_only: true,
-
- // Support: Android 4.0 only, IE 9 only
- // This is in lieu of setting ie for all of mangle, compress, and output
- ie8: true,
preamble: banner
},
sourceMap: {
diff --git a/eslint.config.js b/eslint.config.js
index ad9e3590..b22b02c6 100644
--- a/eslint.config.js
+++ b/eslint.config.js
@@ -99,8 +99,8 @@ export default [
QUnit: false,
sinon: false,
url: false,
- expectWarning: false,
- expectNoWarning: false,
+ expectMessage: false,
+ expectNoMessage: false,
compareVersions: false,
jQueryVersionSince: false,
startIframeTest: false,
@@ -132,8 +132,8 @@ export default [
url: true,
compareVersions: true,
jQueryVersionSince: false,
- expectWarning: true,
- expectNoWarning: true,
+ expectMessage: true,
+ expectNoMessage: true,
startIframeTest: true,
TestManager: true
}
diff --git a/jtr-3.x.yml b/jtr-3.x.yml
deleted file mode 100644
index ecab32bc..00000000
--- a/jtr-3.x.yml
+++ /dev/null
@@ -1,30 +0,0 @@
-version: 1
-
-runs:
- jquery:
- - 3.x-git
- - 3.x-git.min
- - 3.x-git.slim
- - 3.x-git.slim.min
- - 3.7.1
- - 3.7.1.slim
- - 3.6.4
- - 3.6.4.slim
- - 3.5.1
- - 3.5.1.slim
- - 3.4.1
- - 3.4.1.slim
- - 3.3.1
- - 3.3.1.slim
- - 3.2.1
- - 3.2.1.slim
- - 3.1.1
- - 3.1.1.slim
- - 3.0.0
- - 3.0.0.slim
- plugin:
- - dev
- - min
-
-retries: 2
-hard-retries: 1
diff --git a/jtr-git.yml b/jtr-ci.yml
similarity index 77%
rename from jtr-git.yml
rename to jtr-ci.yml
index ff5ef485..eea0990a 100644
--- a/jtr-git.yml
+++ b/jtr-ci.yml
@@ -6,6 +6,8 @@ runs:
- git.min
- git.slim
- git.slim.min
+ - 4.0.0-beta.2
+ - 4.0.0-beta.2.slim
plugin:
- dev
- min
diff --git a/jtr-local.yml b/jtr-local.yml
index fa5058e1..9a7da180 100644
--- a/jtr-local.yml
+++ b/jtr-local.yml
@@ -6,18 +6,7 @@ flags:
- git.min
- git.slim
- git.slim.min
- - 3.x-git
- - 3.x-git.min
- - 3.x-git.slim
- - 3.x-git.slim.min
- - 3.7.1
- - 3.7.1.slim
- - 3.6.4
- - 3.5.1
- - 3.4.1
- - 3.3.1
- - 3.2.1
- - 3.1.1
- - 3.0.0
+ - 4.0.0-beta.2
+ - 4.0.0-beta.2.slim
retries: 1
diff --git a/package-lock.json b/package-lock.json
index 96b7569f..40cf6877 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "jquery-migrate",
- "version": "3.5.3-pre",
+ "version": "4.0.0-pre",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "jquery-migrate",
- "version": "3.5.3-pre",
+ "version": "4.0.0-pre",
"license": "MIT",
"devDependencies": {
"chalk": "5.4.1",
@@ -17,7 +17,7 @@
"eslint-plugin-import": "2.29.1",
"globals": "15.3.0",
"husky": "9.0.11",
- "jquery": "3.7.1",
+ "jquery": "4.0.0-beta.2",
"jquery-test-runner": "0.2.1",
"jsdom": "24.1.0",
"native-promise-only": "0.8.1",
@@ -27,7 +27,7 @@
"uglify-js": "3.9.4"
},
"peerDependencies": {
- "jquery": ">=3 <4"
+ "jquery": ">=4 <5"
}
},
"node_modules/@bazel/runfiles": {
@@ -879,10 +879,11 @@
"license": "MIT"
},
"node_modules/cross-spawn": {
- "version": "7.0.3",
- "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
- "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
+ "version": "7.0.6",
+ "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
+ "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
"dev": true,
+ "license": "MIT",
"dependencies": {
"path-key": "^3.1.0",
"shebang-command": "^2.0.0",
@@ -2421,10 +2422,11 @@
"dev": true
},
"node_modules/jquery": {
- "version": "3.7.1",
- "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.7.1.tgz",
- "integrity": "sha512-m4avr8yL8kmFN8psrbFFFmB/If14iN5o9nw/NgnnM+kybDJpRsAynV2BsfpTYrTRysYUdADVD7CkUUizgkpLfg==",
- "dev": true
+ "version": "4.0.0-beta.2",
+ "resolved": "https://registry.npmjs.org/jquery/-/jquery-4.0.0-beta.2.tgz",
+ "integrity": "sha512-2/cB7q2vtwltOGph8cNaNBRfVRdewrgdmYipXJ9ZYLQOPYjBKHH8+l5ZLVTFV7emKVIPXwDP3excXS0zUcx9kw==",
+ "dev": true,
+ "license": "MIT"
},
"node_modules/jquery-test-runner": {
"version": "0.2.1",
diff --git a/package.json b/package.json
index c52a71ce..b7c3386d 100644
--- a/package.json
+++ b/package.json
@@ -1,9 +1,9 @@
{
"name": "jquery-migrate",
"title": "jQuery Migrate",
- "description": "Migrate older jQuery code to jQuery 3.0+",
+ "description": "Migrate older jQuery code to jQuery 4.x",
"main": "dist/jquery-migrate.js",
- "version": "3.5.3-pre",
+ "version": "4.0.0-pre",
"type": "module",
"homepage": "https://github.com/jquery/jquery-migrate",
"author": {
@@ -34,7 +34,7 @@
"test": "npm run test:node_smoke_tests && npm run test:browser"
},
"peerDependencies": {
- "jquery": ">=3 <4"
+ "jquery": ">=4 <5"
},
"devDependencies": {
"chalk": "5.4.1",
@@ -45,7 +45,7 @@
"eslint-plugin-import": "2.29.1",
"globals": "15.3.0",
"husky": "9.0.11",
- "jquery": "3.7.1",
+ "jquery": "4.0.0-beta.2",
"jquery-test-runner": "0.2.1",
"jsdom": "24.1.0",
"native-promise-only": "0.8.1",
diff --git a/src/jquery/ajax.js b/src/jquery/ajax.js
index 91555749..fba295ee 100644
--- a/src/jquery/ajax.js
+++ b/src/jquery/ajax.js
@@ -1,32 +1,14 @@
-import { jQueryVersionSince } from "../compareVersions.js";
-import { migrateWarn, migratePatchAndWarnFunc, migratePatchFunc } from "../main.js";
+import { migrateWarn } from "../main.js";
// Support jQuery slim which excludes the ajax module
if ( jQuery.ajax ) {
-var oldAjax = jQuery.ajax,
- oldCallbacks = [],
+var oldCallbacks = [],
guid = "migrate-" + Date.now(),
origJsonpCallback = jQuery.ajaxSettings.jsonpCallback,
rjsonp = /(=)\?(?=&|$)|\?\?/,
rquery = /\?/;
-migratePatchFunc( jQuery, "ajax", function() {
- var jQXHR = oldAjax.apply( this, arguments );
-
- // Be sure we got a jQXHR (e.g., not sync)
- if ( jQXHR.promise ) {
- migratePatchAndWarnFunc( jQXHR, "success", jQXHR.done, "jqXHR-methods",
- "jQXHR.success is deprecated and removed" );
- migratePatchAndWarnFunc( jQXHR, "error", jQXHR.fail, "jqXHR-methods",
- "jQXHR.error is deprecated and removed" );
- migratePatchAndWarnFunc( jQXHR, "complete", jQXHR.always, "jqXHR-methods",
- "jQXHR.complete is deprecated and removed" );
- }
-
- return jQXHR;
-}, "jqXHR-methods" );
-
jQuery.ajaxSetup( {
jsonpCallback: function() {
@@ -45,120 +27,95 @@ jQuery.ajaxSetup( {
// Register this prefilter before the jQuery one. Otherwise, a promoted
// request is transformed into one with the script dataType, and we can't
// catch it anymore.
-if ( jQueryVersionSince( "4.0.0" ) ) {
+//
+// Code mostly from:
+// https://github.com/jquery/jquery/blob/fa0058af426c4e482059214c29c29f004254d9a1/src/ajax/jsonp.js#L20-L97
+jQuery.ajaxPrefilter( "+json", function( s, originalSettings, jqXHR ) {
- // Code mostly from:
- // https://github.com/jquery/jquery/blob/fa0058af426c4e482059214c29c29f004254d9a1/src/ajax/jsonp.js#L20-L97
- jQuery.ajaxPrefilter( "+json", function( s, originalSettings, jqXHR ) {
+ if ( !jQuery.migrateIsPatchEnabled( "jsonp-promotion" ) ) {
+ return;
+ }
- if ( !jQuery.migrateIsPatchEnabled( "jsonp-promotion" ) ) {
- return;
+ var callbackName, overwritten, responseContainer,
+ jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
+ "url" :
+ typeof s.data === "string" &&
+ ( s.contentType || "" )
+ .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
+ rjsonp.test( s.data ) && "data"
+ );
+
+ // Handle iff the expected data type is "jsonp" or we have a parameter to set
+ if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
+ migrateWarn( "jsonp-promotion", "JSON-to-JSONP auto-promotion is removed" );
+
+ // Get callback name, remembering preexisting value associated with it
+ callbackName = s.jsonpCallback = typeof s.jsonpCallback === "function" ?
+ s.jsonpCallback() :
+ s.jsonpCallback;
+
+ // Insert callback into url or form data
+ if ( jsonProp ) {
+ s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
+ } else if ( s.jsonp !== false ) {
+ s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
}
- var callbackName, overwritten, responseContainer,
- jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
- "url" :
- typeof s.data === "string" &&
- ( s.contentType || "" )
- .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
- rjsonp.test( s.data ) && "data"
- );
-
- // Handle iff the expected data type is "jsonp" or we have a parameter to set
- if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
- migrateWarn( "jsonp-promotion", "JSON-to-JSONP auto-promotion is deprecated" );
-
- // Get callback name, remembering preexisting value associated with it
- callbackName = s.jsonpCallback = typeof s.jsonpCallback === "function" ?
- s.jsonpCallback() :
- s.jsonpCallback;
-
- // Insert callback into url or form data
- if ( jsonProp ) {
- s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
- } else if ( s.jsonp !== false ) {
- s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
+ // Use data converter to retrieve json after script execution
+ s.converters[ "script json" ] = function() {
+ if ( !responseContainer ) {
+ jQuery.error( callbackName + " was not called" );
}
+ return responseContainer[ 0 ];
+ };
- // Use data converter to retrieve json after script execution
- s.converters[ "script json" ] = function() {
- if ( !responseContainer ) {
- jQuery.error( callbackName + " was not called" );
- }
- return responseContainer[ 0 ];
- };
+ // Force json dataType
+ s.dataTypes[ 0 ] = "json";
- // Force json dataType
- s.dataTypes[ 0 ] = "json";
+ // Install callback
+ overwritten = window[ callbackName ];
+ window[ callbackName ] = function() {
+ responseContainer = arguments;
+ };
- // Install callback
- overwritten = window[ callbackName ];
- window[ callbackName ] = function() {
- responseContainer = arguments;
- };
+ // Clean-up function (fires after converters)
+ jqXHR.always( function() {
- // Clean-up function (fires after converters)
- jqXHR.always( function() {
+ // If previous value didn't exist - remove it
+ if ( overwritten === undefined ) {
+ jQuery( window ).removeProp( callbackName );
- // If previous value didn't exist - remove it
- if ( overwritten === undefined ) {
- jQuery( window ).removeProp( callbackName );
-
- // Otherwise restore preexisting value
- } else {
- window[ callbackName ] = overwritten;
- }
-
- // Save back as free
- if ( s[ callbackName ] ) {
-
- // Make sure that re-using the options doesn't screw things around
- s.jsonpCallback = originalSettings.jsonpCallback;
-
- // Save the callback name for future use
- oldCallbacks.push( callbackName );
- }
+ // Otherwise restore preexisting value
+ } else {
+ window[ callbackName ] = overwritten;
+ }
- // Call if it was a function and we have a response
- if ( responseContainer && typeof overwritten === "function" ) {
- overwritten( responseContainer[ 0 ] );
- }
+ // Save back as free
+ if ( s[ callbackName ] ) {
- responseContainer = overwritten = undefined;
- } );
+ // Make sure that re-using the options doesn't screw things around
+ s.jsonpCallback = originalSettings.jsonpCallback;
- // Delegate to script
- return "script";
- }
- } );
-} else {
+ // Save the callback name for future use
+ oldCallbacks.push( callbackName );
+ }
- // jQuery <4 already contains this prefixer; don't duplicate the whole logic,
- // but only enough to know when to warn.
- jQuery.ajaxPrefilter( "+json", function( s ) {
+ // Call if it was a function and we have a response
+ if ( responseContainer && typeof overwritten === "function" ) {
+ overwritten( responseContainer[ 0 ] );
+ }
- if ( !jQuery.migrateIsPatchEnabled( "jsonp-promotion" ) ) {
- return;
- }
-
- // Warn if JSON-to-JSONP auto-promotion happens.
- if ( s.jsonp !== false && ( rjsonp.test( s.url ) ||
- typeof s.data === "string" &&
- ( s.contentType || "" )
- .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
- rjsonp.test( s.data )
- ) ) {
- migrateWarn( "jsonp-promotion", "JSON-to-JSONP auto-promotion is deprecated" );
- }
- } );
-}
+ responseContainer = overwritten = undefined;
+ } );
+ // Delegate to script
+ return "script";
+ }
+} );
-// Don't trigger the above logic in jQuery >=4 by default as the JSON-to-JSONP
-// auto-promotion behavior is gone in jQuery 4.0 and as it has security implications,
-// we don't want to restore the legacy behavior by default.
-if ( jQueryVersionSince( "4.0.0" ) ) {
- jQuery.migrateDisablePatches( "jsonp-promotion" );
-}
+// Don't trigger the above logic by default as the JSON-to-JSONP auto-promotion
+// behavior is gone in jQuery 4.0 and as it has security implications, we don't
+// want to restore the legacy behavior by default.
+jQuery.migrateDisablePatches( "jsonp-promotion" );
}
diff --git a/src/jquery/attributes.js b/src/jquery/attributes.js
index f76b1499..69e5b259 100644
--- a/src/jquery/attributes.js
+++ b/src/jquery/attributes.js
@@ -1,13 +1,10 @@
import { migratePatchFunc, migrateWarn } from "../main.js";
-import { jQueryVersionSince } from "../compareVersions.js";
-var oldRemoveAttr = jQuery.fn.removeAttr,
- oldJQueryAttr = jQuery.attr,
+var oldJQueryAttr = jQuery.attr,
oldToggleClass = jQuery.fn.toggleClass,
booleans = "checked|selected|async|autofocus|autoplay|controls|defer|" +
"disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
rbooleans = new RegExp( "^(?:" + booleans + ")$", "i" ),
- rmatchNonSpace = /\S+/g,
// Some formerly boolean attributes gained new values with special meaning.
// Skip the old boolean attr logic for those values.
@@ -37,14 +34,7 @@ jQuery.each( booleans.split( "|" ), function( _i, name ) {
"Boolean attribute '" + name +
"' value is different from its lowercased name" );
- // jQuery <4 attr hooks setup is complex: there are attr
- // hooks, bool hooks and selector attr handles. Only
- // implement the logic in jQuery >=4 where it's missing
- // and there are only attr hooks.
- if ( jQueryVersionSince( "4.0.0" ) ) {
- return name.toLowerCase();
- }
- return null;
+ return name.toLowerCase();
}
}
@@ -72,20 +62,6 @@ jQuery.each( booleans.split( "|" ), function( _i, name ) {
}
return name;
}
- } else if ( !jQueryVersionSince( "4.0.0" ) ) {
-
- // jQuery <4 uses a private `boolHook` for the boolean attribute
- // setter. It's only activated if `attrHook` is not set, but we set
- // it here in Migrate. Since we cannot access it, let's just repeat
- // its contents here.
- if ( value === false ) {
-
- // Remove boolean attributes when set to false
- jQuery.removeAttr( elem, name );
- } else {
- elem.setAttribute( name, name );
- }
- return name;
}
}
};
@@ -114,34 +90,6 @@ migratePatchFunc( jQuery, "attr", function( elem, name, value ) {
return oldJQueryAttr.apply( this, arguments );
}, "attr-false" );
-migratePatchFunc( jQuery.fn, "removeAttr", function( name ) {
- var self = this,
- patchNeeded = false;
-
- jQuery.each( name.match( rmatchNonSpace ), function( _i, attr ) {
- if ( rbooleans.test( attr ) ) {
-
- // Only warn if at least a single node had the property set to
- // something else than `false`. Otherwise, this Migrate patch
- // doesn't influence the behavior and there's no need to set or warn.
- self.each( function() {
- if ( jQuery( this ).prop( attr ) !== false ) {
- patchNeeded = true;
- return false;
- }
- } );
- }
-
- if ( patchNeeded ) {
- migrateWarn( "removeAttr-bool",
- "jQuery.fn.removeAttr no longer sets boolean properties: " + attr );
- self.prop( attr, false );
- }
- } );
-
- return oldRemoveAttr.apply( this, arguments );
-}, "removeAttr-bool" );
-
migratePatchFunc( jQuery.fn, "toggleClass", function( state ) {
// Only deprecating no-args or single boolean arg
@@ -150,7 +98,7 @@ migratePatchFunc( jQuery.fn, "toggleClass", function( state ) {
return oldToggleClass.apply( this, arguments );
}
- migrateWarn( "toggleClass-bool", "jQuery.fn.toggleClass( boolean ) is deprecated" );
+ migrateWarn( "toggleClass-bool", "jQuery.fn.toggleClass( [ boolean ] ) is removed" );
// Toggle entire class name of each element
return this.each( function() {
diff --git a/src/jquery/core.js b/src/jquery/core.js
index 7d92fefd..d9cb256a 100644
--- a/src/jquery/core.js
+++ b/src/jquery/core.js
@@ -1,238 +1,100 @@
-import { jQueryVersionSince } from "../compareVersions.js";
-import {
- migratePatchFunc,
- migrateWarn,
- migratePatchAndWarnFunc,
- migrateWarnProp
-} from "../main.js";
+import { migrateWarnProp, migratePatchAndWarnFunc, migratePatchAndInfoFunc } from "../main.js";
import "../disablePatches.js";
-var findProp,
- arr = [],
+var arr = [],
push = arr.push,
- slice = arr.slice,
sort = arr.sort,
splice = arr.splice,
class2type = {},
- oldInit = jQuery.fn.init,
- oldFind = jQuery.find,
-
- rattrHashTest = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/,
- rattrHashGlob = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/g,
// Require that the "whitespace run" starts from a non-whitespace
// to avoid O(N^2) behavior when the engine would try matching "\s+$" at each space position.
rtrim = /^[\s\uFEFF\xA0]+|([^\s\uFEFF\xA0])[\s\uFEFF\xA0]+$/g;
-function isFunction( obj ) {
-
- // Support: Chrome <=57, Firefox <=52
- // In some browsers, typeof returns "function" for HTML