Effect: Define the jQuery variable before jQuery Color gets imported

We need to create a local jQuery because jQuery Color relies on it and the
global may not exist with AMD and a custom build (trac-10199). This worked
in UI 1.12 but stopped in 1.13 as jQuery Color is now sourced as an AMD module
and the variable started being defined after jQuery Color code. To restore the
proper order, move the variable declaration to a separate small module loaded
before jQuery Color.

Closes gh-1973
This commit is contained in:
Michał Gołębiowski-Owczarek 2021-09-03 14:42:30 +02:00 committed by GitHub
parent eda9f3b0d6
commit 2fd224d5cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 5 deletions

View File

@ -23,6 +23,7 @@
// AMD. Register as an anonymous module.
define( [
"jquery",
"./jquery-var-for-color",
"./vendor/jquery-color/jquery.color",
"./version"
], factory );
@ -36,11 +37,7 @@
var dataSpace = "ui-effects-",
dataSpaceStyle = "ui-effects-style",
dataSpaceAnimated = "ui-effects-animated",
// Create a local jQuery because jQuery Color relies on it and the
// global may not exist with AMD and a custom build (#10199)
jQuery = $;
dataSpaceAnimated = "ui-effects-animated";
$.effects = {
effect: {}

22
ui/jquery-var-for-color.js vendored Normal file
View File

@ -0,0 +1,22 @@
( function( factory ) {
"use strict";
if ( typeof define === "function" && define.amd ) {
// AMD. Register as an anonymous module.
define( [ "jquery", "./version" ], factory );
} else {
// Browser globals
factory( jQuery );
}
} )( function( $ ) {
"use strict";
// Create a local jQuery because jQuery Color relies on it and the
// global may not exist with AMD and a custom build (#10199).
// This module is a noop if used as a regular AMD module.
// eslint-disable-next-line no-unused-vars
var jQuery = $;
} );