]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Add `Util.jQuery` which will detect jQuery instead of relying on global `$` (#24513)
authorJohann-S <johann.servoire@gmail.com>
Mon, 23 Oct 2017 07:35:27 +0000 (09:35 +0200)
committerXhmikosR <xhmikosr@gmail.com>
Mon, 23 Oct 2017 07:35:27 +0000 (10:35 +0300)
14 files changed:
js/src/alert.js
js/src/button.js
js/src/carousel.js
js/src/collapse.js
js/src/dropdown.js
js/src/index.js
js/src/modal.js
js/src/popover.js
js/src/scrollspy.js
js/src/tab.js
js/src/tooltip.js
js/src/util.js
js/tests/index.html
js/tests/unit/util.js [new file with mode: 0644]

index 420aa84a306a4f2038c7dce5e07588f4dda4ba69..2b967145f682f76af25364f540a7a56097c0b6cd 100644 (file)
@@ -189,6 +189,6 @@ const Alert = (() => {
 
   return Alert
 
-})($)
+})(Util.jQuery)
 
 export default Alert
index 9227da9516d9314f85c81215167b0f069f7c1578..87e724346fb018afc3b6ea7b1632842636922a46 100644 (file)
@@ -1,4 +1,6 @@
 import $ from 'jquery'
+import Util from './util'
+
 /**
  * --------------------------------------------------------------------------
  * Bootstrap (v4.0.0-beta.2): button.js
@@ -182,6 +184,6 @@ const Button = (() => {
 
   return Button
 
-})($)
+})(Util.jQuery)
 
 export default Button
index 964f7fda6e08f8740bdda55a17bb5b645a737f8c..b5cbf98b48fd6e431dd49391714374ddf5b5c8a0 100644 (file)
@@ -519,6 +519,6 @@ const Carousel = (() => {
 
   return Carousel
 
-})($)
+})(Util.jQuery)
 
 export default Carousel
index 8e84d7b59e7a898786e4b226f217b3c944414353..9a21eb7d81496d91f6606f9bd00edbd1c219c029 100644 (file)
@@ -404,6 +404,6 @@ const Collapse = (() => {
 
   return Collapse
 
-})($)
+})(Util.jQuery)
 
 export default Collapse
index 8fdddd68972d89cce70d5de038cd4ad24ab9bfc1..48f87c5aa19e66dbba610f51307467f9984c0bc0 100644 (file)
@@ -445,6 +445,6 @@ const Dropdown = (() => {
 
   return Dropdown
 
-})($, Popper)
+})(Util.jQuery, Popper)
 
 export default Dropdown
index f30b94c57619b73c17dba8b471a67ec6009793e6..1697a709b7b2acb5bf315fecf99e8a6381899a17 100644 (file)
@@ -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,
index 07fdc9f4fc4966acb310db4517ea311e6a535552..cb7bef0ce3154712147ba632d10c427b913dd3c3 100644 (file)
@@ -585,6 +585,6 @@ const Modal = (() => {
 
   return Modal
 
-})($)
+})(Util.jQuery)
 
 export default Modal
index ff697d85acf9bcbb1372b21c088a6b86a7d7dc9a..28cb511fc83d36d84f7b0c3a2b86be44672b751a 100644 (file)
@@ -1,5 +1,6 @@
 import $ from 'jquery'
 import Tooltip from './tooltip'
+import Util from './util'
 
 
 /**
@@ -189,6 +190,6 @@ const Popover = (() => {
 
   return Popover
 
-})($)
+})(Util.jQuery)
 
 export default Popover
index a0e24dd2291c7fe2f90f494522d5aaf0c522fc1e..12667cc95710e383780d6a8dc10c6197c4313992 100644 (file)
@@ -335,6 +335,6 @@ const ScrollSpy = (() => {
 
   return ScrollSpy
 
-})($)
+})(Util.jQuery)
 
 export default ScrollSpy
index 982121cc00273b9a7b161f9cdf52e9a3b8822920..f1d9ec0c82c46d9f1d52ccc5f6a0db1f7f062895 100644 (file)
@@ -282,6 +282,6 @@ const Tab = (() => {
 
   return Tab
 
-})($)
+})(Util.jQuery)
 
 export default Tab
index ee721a19d0870cad1e3e51d588b892f5c968fa04..39ef2594b9338287fcbecb8bceea5be166fca16f 100644 (file)
@@ -728,6 +728,6 @@ const Tooltip = (() => {
 
   return Tooltip
 
-})($, Popper)
+})(Util.jQuery, Popper)
 
 export default Tooltip
index 16d114b1ab999963d2793549329630ab77185ec0..e3e77979319a937cf9fab9b7b5d23576ff2f9393 100644 (file)
@@ -154,6 +154,10 @@ const Util = (() => {
           }
         }
       }
+    },
+
+    get jQuery() {
+      return window.jQuery || window.$
     }
   }
 
index 2383fce6e6d7088878b09354384ba04154c31e32..0385b8a2baf11746fe4be982bc8c1e1a18b76931 100644 (file)
     <script src="unit/tab.js"></script>
     <script src="unit/tooltip.js"></script>
     <script src="unit/popover.js"></script>
+    <script src="unit/util.js"></script>
   </head>
   <body>
     <div id="qunit-container">
diff --git a/js/tests/unit/util.js b/js/tests/unit/util.js
new file mode 100644 (file)
index 0000000..c341204
--- /dev/null
@@ -0,0 +1,19 @@
+$(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
+  })
+})