Skip to content

Commit 5ee8f69

Browse files
authoredMar 14, 2022
Core: Support selectively disabling Migrate patches
This adds three new APIs: * `jQuery.migrateDisablePatches` * `jQuery.migrateEnablePatches` * `jQuery.migrateIsPatchEnabled` allowing to selectively disable/re-enable patches in runtime. Source code is refactored to avoid manually overwriting jQuery methods in favor of using `migratePatchAndWarnFunc` or `migratePatchFunc` which cooperate with above methods. The `jQuery.UNSAFE_restoreLegacyHtmlPrefilter` API, introduced in Migrate 3.2.0, is now deprecated in favor of calling: ```js jQuery.migrateEnablePatches( "self-closed-tags" ); ``` The commit also reorganizes test code a bit, grouping modules testing patches to jQuery modules in a separate directory and extracting tests of Migrate APIs out of `core.js` to a separate `migrate.js` file. Helper files are now put in `test/data/` and unit tests in `test/unit/`; jQuery patch tests are in `test/unit/jquery/`. Fixes gh-449 Closes gh-450
1 parent c6d3ca2 commit 5ee8f69

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+557
-361
lines changed
 

‎Gruntfile.js

+15-14
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,21 @@ module.exports = function( grunt ) {
1111
"dist/jquery-migrate.min.js",
1212
"test/data/compareVersions.js",
1313

14-
"test/testinit.js",
15-
"test/migrate.js",
16-
"test/core.js",
17-
"test/ajax.js",
18-
"test/attributes.js",
19-
"test/css.js",
20-
"test/data.js",
21-
"test/deferred.js",
22-
"test/effects.js",
23-
"test/event.js",
24-
"test/manipulation.js",
25-
"test/offset.js",
26-
"test/serialize.js",
27-
"test/traversing.js",
14+
"test/data/testinit.js",
15+
"test/data/test-utils.js",
16+
"test/unit/migrate.js",
17+
"test/unit/jquery/core.js",
18+
"test/unit/jquery/ajax.js",
19+
"test/unit/jquery/attributes.js",
20+
"test/unit/jquery/css.js",
21+
"test/unit/jquery/data.js",
22+
"test/unit/jquery/deferred.js",
23+
"test/unit/jquery/effects.js",
24+
"test/unit/jquery/event.js",
25+
"test/unit/jquery/manipulation.js",
26+
"test/unit/jquery/offset.js",
27+
"test/unit/jquery/serialize.js",
28+
"test/unit/jquery/traversing.js",
2829

2930
{ pattern: "dist/jquery-migrate.js", included: false, served: true },
3031
{ pattern: "test/**/*.@(js|json|css|jpg|html|xml)", included: false, served: true }

‎README.md

+8
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ This plugin adds some properties to the `jQuery` object that can be used to prog
5656

5757
`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.
5858

59+
`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.
60+
61+
`jQuery.migrateDisablePatches`: Disables patches by their codes.
62+
63+
`jQuery.migrateIsPatchEnabled`: Returns `true` if a patch of a provided code is enabled and `false` otherwise.
64+
65+
`jQuery.UNSAFE_restoreLegacyHtmlPrefilter`: A deprecated alias of `jQuery.migrateEnablePatches( "self-closed-tags" )`
66+
5967
## Reporting problems
6068

6169
Bugs that only occur when the jQuery Migrate plugin is used should be reported in the [jQuery Migrate Issue Tracker](https://github.com/jquery/jquery-migrate/issues) and should be accompanied by an executable test case that demonstrates the bug. The easiest way to do this is via an online test tool such as [jsFiddle.net](https://jsFiddle.net/) or [jsbin.com](https://jsbin.com). Use the development version when you are reporting bugs.

0 commit comments

Comments
 (0)
Please sign in to comment.