From 62fbb23ee61999e362cd8ade6073732a46466077 Mon Sep 17 00:00:00 2001 From: Johann-S Date: Tue, 24 Oct 2017 10:12:45 +0200 Subject: [PATCH] Change Rollup config to wrap our dist files with jQuery instead of $ --- build/rollup.config.js | 2 +- js/src/alert.js | 4 ++-- js/src/button.js | 5 ++--- js/src/carousel.js | 4 ++-- js/src/collapse.js | 4 ++-- js/src/dropdown.js | 4 ++-- js/src/index.js | 4 ++-- js/src/modal.js | 4 ++-- js/src/popover.js | 5 ++--- js/src/scrollspy.js | 4 ++-- js/src/tab.js | 4 ++-- js/src/tooltip.js | 4 ++-- js/src/util.js | 6 +----- js/tests/index.html | 1 - js/tests/unit/util.js | 19 ------------------- 15 files changed, 24 insertions(+), 50 deletions(-) delete mode 100644 js/tests/unit/util.js diff --git a/build/rollup.config.js b/build/rollup.config.js index 9faeb08826..f9a4706160 100644 --- a/build/rollup.config.js +++ b/build/rollup.config.js @@ -20,7 +20,7 @@ const plugins = [ }) ] const globals = { - jquery: '$', + jquery: 'jQuery', // ensure we use jQuery which is always available even in noConflict mode 'popper.js': 'Popper' } diff --git a/js/src/alert.js b/js/src/alert.js index 2b967145f6..8d52e1591b 100644 --- a/js/src/alert.js +++ b/js/src/alert.js @@ -9,7 +9,7 @@ import Util from './util' * -------------------------------------------------------------------------- */ -const Alert = (() => { +const Alert = (($) => { /** @@ -189,6 +189,6 @@ const Alert = (() => { return Alert -})(Util.jQuery) +})($) export default Alert diff --git a/js/src/button.js b/js/src/button.js index 87e724346f..5632998a3f 100644 --- a/js/src/button.js +++ b/js/src/button.js @@ -1,5 +1,4 @@ import $ from 'jquery' -import Util from './util' /** * -------------------------------------------------------------------------- @@ -8,7 +7,7 @@ import Util from './util' * -------------------------------------------------------------------------- */ -const Button = (() => { +const Button = (($) => { /** @@ -184,6 +183,6 @@ const Button = (() => { return Button -})(Util.jQuery) +})($) export default Button diff --git a/js/src/carousel.js b/js/src/carousel.js index b5cbf98b48..10ed2203ed 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -9,7 +9,7 @@ import Util from './util' * -------------------------------------------------------------------------- */ -const Carousel = (() => { +const Carousel = (($) => { /** @@ -519,6 +519,6 @@ const Carousel = (() => { return Carousel -})(Util.jQuery) +})($) export default Carousel diff --git a/js/src/collapse.js b/js/src/collapse.js index 9a21eb7d81..f907aec54d 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -9,7 +9,7 @@ import Util from './util' * -------------------------------------------------------------------------- */ -const Collapse = (() => { +const Collapse = (($) => { /** @@ -404,6 +404,6 @@ const Collapse = (() => { return Collapse -})(Util.jQuery) +})($) export default Collapse diff --git a/js/src/dropdown.js b/js/src/dropdown.js index 48f87c5aa1..e3331ac183 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -10,7 +10,7 @@ import Util from './util' * -------------------------------------------------------------------------- */ -const Dropdown = (() => { +const Dropdown = (($) => { /** * Check for Popper dependency @@ -445,6 +445,6 @@ const Dropdown = (() => { return Dropdown -})(Util.jQuery, Popper) +})($, Popper) export default Dropdown diff --git a/js/src/index.js b/js/src/index.js index 1697a709b7..51d09b4e29 100644 --- a/js/src/index.js +++ b/js/src/index.js @@ -18,7 +18,7 @@ import Util from './util' * -------------------------------------------------------------------------- */ -(() => { +(($) => { if (typeof $ === 'undefined') { throw new Error('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.') } @@ -33,7 +33,7 @@ import Util from './util' if (version[0] < ltMajor && version[1] < minMinor || version[0] === minMajor && version[1] === minMinor && version[2] < minPatch || version[0] >= maxMajor) { throw new Error('Bootstrap\'s JavaScript requires at least jQuery v1.9.1 but less than v4.0.0') } -})(Util.jQuery) +})($) export { Util, diff --git a/js/src/modal.js b/js/src/modal.js index cb7bef0ce3..95565aabcc 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -9,7 +9,7 @@ import Util from './util' * -------------------------------------------------------------------------- */ -const Modal = (() => { +const Modal = (($) => { /** @@ -585,6 +585,6 @@ const Modal = (() => { return Modal -})(Util.jQuery) +})($) export default Modal diff --git a/js/src/popover.js b/js/src/popover.js index 28cb511fc8..4fb96a792e 100644 --- a/js/src/popover.js +++ b/js/src/popover.js @@ -1,6 +1,5 @@ import $ from 'jquery' import Tooltip from './tooltip' -import Util from './util' /** @@ -10,7 +9,7 @@ import Util from './util' * -------------------------------------------------------------------------- */ -const Popover = (() => { +const Popover = (($) => { /** @@ -190,6 +189,6 @@ const Popover = (() => { return Popover -})(Util.jQuery) +})($) export default Popover diff --git a/js/src/scrollspy.js b/js/src/scrollspy.js index 12667cc957..3a13d954ac 100644 --- a/js/src/scrollspy.js +++ b/js/src/scrollspy.js @@ -9,7 +9,7 @@ import Util from './util' * -------------------------------------------------------------------------- */ -const ScrollSpy = (() => { +const ScrollSpy = (($) => { /** @@ -335,6 +335,6 @@ const ScrollSpy = (() => { return ScrollSpy -})(Util.jQuery) +})($) export default ScrollSpy diff --git a/js/src/tab.js b/js/src/tab.js index f1d9ec0c82..1d4178687d 100644 --- a/js/src/tab.js +++ b/js/src/tab.js @@ -9,7 +9,7 @@ import Util from './util' * -------------------------------------------------------------------------- */ -const Tab = (() => { +const Tab = (($) => { /** @@ -282,6 +282,6 @@ const Tab = (() => { return Tab -})(Util.jQuery) +})($) export default Tab diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 39ef2594b9..a3fc93c913 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -10,7 +10,7 @@ import Util from './util' * -------------------------------------------------------------------------- */ -const Tooltip = (() => { +const Tooltip = (($) => { /** * Check for Popper dependency @@ -728,6 +728,6 @@ const Tooltip = (() => { return Tooltip -})(Util.jQuery, Popper) +})($, Popper) export default Tooltip diff --git a/js/src/util.js b/js/src/util.js index 1fa55494ea..71f93a7c50 100644 --- a/js/src/util.js +++ b/js/src/util.js @@ -7,7 +7,7 @@ import $ from 'jquery' * -------------------------------------------------------------------------- */ -const Util = (() => { +const Util = (($) => { /** @@ -152,10 +152,6 @@ const Util = (() => { } } } - }, - - get jQuery() { - return window.jQuery || window.$ } } diff --git a/js/tests/index.html b/js/tests/index.html index 0385b8a2ba..2383fce6e6 100644 --- a/js/tests/index.html +++ b/js/tests/index.html @@ -119,7 +119,6 @@ -
diff --git a/js/tests/unit/util.js b/js/tests/unit/util.js deleted file mode 100644 index c3412041eb..0000000000 --- a/js/tests/unit/util.js +++ /dev/null @@ -1,19 +0,0 @@ -$(function () { - 'use strict' - - QUnit.module('Util') - - QUnit.test('Util.jQuery should find window.jQuery if window.$ is not available', function (assert) { - assert.expect(1) - delete window.$ - assert.strictEqual(Util.jQuery, window.jQuery) - window.$ = Util.jQuery - }) - - QUnit.test('Util.jQuery should find window.$ if window.jQuery is not available', function (assert) { - assert.expect(1) - delete window.jQuery - assert.strictEqual(Util.jQuery, window.$) - window.jQuery = Util.jQuery - }) -})