Skip to content

Commit

Permalink
Core: Accept only jQuery 3.x-4.x
Browse files Browse the repository at this point in the history
Closes gh-470
  • Loading branch information
mgol committed Aug 29, 2022
1 parent 7ae3a9f commit 562f26c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
13 changes: 13 additions & 0 deletions README.md
Expand Up @@ -7,6 +7,19 @@ Upgrading libraries such as jQuery can be a lot of work, when breaking changes h

That way you can spot and fix what otherwise would have been errors, until you no longer need jQuery Migrate and can remove it.

## Version compatibility

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<sup>[1]</sup> |
| 4.x | 3.x / 4.x<sup>[1]</sup> |

[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.

## Usage

In your web page, load this plugin *after* the script tag for jQuery, for example:
Expand Down
7 changes: 4 additions & 3 deletions src/main.js
Expand Up @@ -10,9 +10,10 @@ import "./disablePatches.js";
return;
}

// Need jQuery 3.0.0+ and no older Migrate loaded
if ( !jQuery || !jQueryVersionSince( "3.0.0" ) ) {
window.console.log( "JQMIGRATE: jQuery 3.0.0+ REQUIRED" );
// Need jQuery 3.x-4.x and no older Migrate loaded
if ( !jQuery || !jQueryVersionSince( "3.0.0" ) ||
jQueryVersionSince( "5.0.0" ) ) {
window.console.log( "JQMIGRATE: jQuery 3.x-4.x REQUIRED" );
}
if ( jQuery.migrateWarnings ) {
window.console.log( "JQMIGRATE: Migrate plugin loaded multiple times" );
Expand Down

0 comments on commit 562f26c

Please sign in to comment.