-
Notifications
You must be signed in to change notification settings - Fork 473
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
41 changed files
with
557 additions
and
361 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// A map from disabled patch codes to `true`. This should really | ||
// be a `Set` but those are unsupported in IE. | ||
var disabledPatches = Object.create( null ); | ||
|
||
// Don't apply patches for specified codes. Helpful for code bases | ||
// where some Migrate warnings have been addressed and it's desirable | ||
// to avoid needless patches or false positives. | ||
jQuery.migrateDisablePatches = function() { | ||
var i; | ||
for ( i = 0; i < arguments.length; i++ ) { | ||
disabledPatches[ arguments[ i ] ] = true; | ||
} | ||
}; | ||
|
||
// Allow enabling patches disabled via `jQuery.migrateDisablePatches`. | ||
// Helpful if you want to disable a patch only for some code that won't | ||
// be updated soon to be able to focus on other warnings - and enable it | ||
// immediately after such a call: | ||
// ```js | ||
// jQuery.migrateDisablePatches( "workaroundA" ); | ||
// elem.pluginViolatingWarningA( "pluginMethod" ); | ||
// jQuery.migrateEnablePatches( "workaroundA" ); | ||
// ``` | ||
jQuery.migrateEnablePatches = function() { | ||
var i; | ||
for ( i = 0; i < arguments.length; i++ ) { | ||
delete disabledPatches[ arguments[ i ] ]; | ||
} | ||
}; | ||
|
||
jQuery.migrateIsPatchEnabled = function( patchCode ) { | ||
return !disabledPatches[ patchCode ]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.