Skip to content

Commit 2fd224d

Browse files
authored
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
1 parent eda9f3b commit 2fd224d

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

ui/effect.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
// AMD. Register as an anonymous module.
2424
define( [
2525
"jquery",
26+
"./jquery-var-for-color",
2627
"./vendor/jquery-color/jquery.color",
2728
"./version"
2829
], factory );
@@ -36,11 +37,7 @@
3637

3738
var dataSpace = "ui-effects-",
3839
dataSpaceStyle = "ui-effects-style",
39-
dataSpaceAnimated = "ui-effects-animated",
40-
41-
// Create a local jQuery because jQuery Color relies on it and the
42-
// global may not exist with AMD and a custom build (#10199)
43-
jQuery = $;
40+
dataSpaceAnimated = "ui-effects-animated";
4441

4542
$.effects = {
4643
effect: {}

ui/jquery-var-for-color.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
( function( factory ) {
2+
"use strict";
3+
4+
if ( typeof define === "function" && define.amd ) {
5+
6+
// AMD. Register as an anonymous module.
7+
define( [ "jquery", "./version" ], factory );
8+
} else {
9+
10+
// Browser globals
11+
factory( jQuery );
12+
}
13+
} )( function( $ ) {
14+
"use strict";
15+
16+
// Create a local jQuery because jQuery Color relies on it and the
17+
// global may not exist with AMD and a custom build (#10199).
18+
// This module is a noop if used as a regular AMD module.
19+
// eslint-disable-next-line no-unused-vars
20+
var jQuery = $;
21+
22+
} );

0 commit comments

Comments
 (0)