diff options
| author | Mark Otto <[email protected]> | 2017-10-25 12:31:33 -0700 |
|---|---|---|
| committer | Mark Otto <[email protected]> | 2017-10-25 12:31:33 -0700 |
| commit | 59bf81f649c8cb171a9f9e052eb40032aecbcf11 (patch) | |
| tree | 0190bde8182a0fe8c47dbc7645d744f0970ba675 /js | |
| parent | 0c40a5bf67056780abbea77894542741f51e2968 (diff) | |
| parent | 988327032d6b76fdb70075feb7254bcb053ec117 (diff) | |
| download | bootstrap-59bf81f649c8cb171a9f9e052eb40032aecbcf11.tar.xz bootstrap-59bf81f649c8cb171a9f9e052eb40032aecbcf11.zip | |
Merge branch 'v4-dev' of https://github.com/twbs/bootstrap into v4-dev
Diffstat (limited to 'js')
| -rw-r--r-- | js/src/alert.js | 2 | ||||
| -rw-r--r-- | js/src/button.js | 3 | ||||
| -rw-r--r-- | js/src/carousel.js | 2 | ||||
| -rw-r--r-- | js/src/collapse.js | 2 | ||||
| -rw-r--r-- | js/src/dropdown.js | 2 | ||||
| -rw-r--r-- | js/src/index.js | 2 | ||||
| -rw-r--r-- | js/src/modal.js | 2 | ||||
| -rw-r--r-- | js/src/popover.js | 2 | ||||
| -rw-r--r-- | js/src/scrollspy.js | 2 | ||||
| -rw-r--r-- | js/src/tab.js | 2 | ||||
| -rw-r--r-- | js/src/tooltip.js | 2 | ||||
| -rw-r--r-- | js/src/util.js | 4 | ||||
| -rw-r--r-- | js/tests/index.html | 1 | ||||
| -rw-r--r-- | js/tests/unit/util.js | 57 |
14 files changed, 71 insertions, 14 deletions
diff --git a/js/src/alert.js b/js/src/alert.js index 420aa84a3..8d52e1591 100644 --- a/js/src/alert.js +++ b/js/src/alert.js @@ -9,7 +9,7 @@ import Util from './util' * -------------------------------------------------------------------------- */ -const Alert = (() => { +const Alert = (($) => { /** diff --git a/js/src/button.js b/js/src/button.js index 9227da951..5632998a3 100644 --- a/js/src/button.js +++ b/js/src/button.js @@ -1,4 +1,5 @@ import $ from 'jquery' + /** * -------------------------------------------------------------------------- * Bootstrap (v4.0.0-beta.2): button.js @@ -6,7 +7,7 @@ import $ from 'jquery' * -------------------------------------------------------------------------- */ -const Button = (() => { +const Button = (($) => { /** diff --git a/js/src/carousel.js b/js/src/carousel.js index 964f7fda6..10ed2203e 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -9,7 +9,7 @@ import Util from './util' * -------------------------------------------------------------------------- */ -const Carousel = (() => { +const Carousel = (($) => { /** diff --git a/js/src/collapse.js b/js/src/collapse.js index 8e84d7b59..f907aec54 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -9,7 +9,7 @@ import Util from './util' * -------------------------------------------------------------------------- */ -const Collapse = (() => { +const Collapse = (($) => { /** diff --git a/js/src/dropdown.js b/js/src/dropdown.js index 8fdddd689..e3331ac18 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 diff --git a/js/src/index.js b/js/src/index.js index f30b94c57..51d09b4e2 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.') } diff --git a/js/src/modal.js b/js/src/modal.js index 07fdc9f4f..95565aabc 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -9,7 +9,7 @@ import Util from './util' * -------------------------------------------------------------------------- */ -const Modal = (() => { +const Modal = (($) => { /** diff --git a/js/src/popover.js b/js/src/popover.js index ff697d85a..4fb96a792 100644 --- a/js/src/popover.js +++ b/js/src/popover.js @@ -9,7 +9,7 @@ import Tooltip from './tooltip' * -------------------------------------------------------------------------- */ -const Popover = (() => { +const Popover = (($) => { /** diff --git a/js/src/scrollspy.js b/js/src/scrollspy.js index a0e24dd22..3a13d954a 100644 --- a/js/src/scrollspy.js +++ b/js/src/scrollspy.js @@ -9,7 +9,7 @@ import Util from './util' * -------------------------------------------------------------------------- */ -const ScrollSpy = (() => { +const ScrollSpy = (($) => { /** diff --git a/js/src/tab.js b/js/src/tab.js index 982121cc0..1d4178687 100644 --- a/js/src/tab.js +++ b/js/src/tab.js @@ -9,7 +9,7 @@ import Util from './util' * -------------------------------------------------------------------------- */ -const Tab = (() => { +const Tab = (($) => { /** diff --git a/js/src/tooltip.js b/js/src/tooltip.js index ee721a19d..a3fc93c91 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 diff --git a/js/src/util.js b/js/src/util.js index 16d114b1a..71f93a7c5 100644 --- a/js/src/util.js +++ b/js/src/util.js @@ -7,7 +7,7 @@ import $ from 'jquery' * -------------------------------------------------------------------------- */ -const Util = (() => { +const Util = (($) => { /** @@ -22,8 +22,6 @@ const Util = (() => { const TransitionEndEvent = { WebkitTransition : 'webkitTransitionEnd', - MozTransition : 'transitionend', - OTransition : 'oTransitionEnd otransitionend', transition : 'transitionend' } diff --git a/js/tests/index.html b/js/tests/index.html index 2383fce6e..0385b8a2b 100644 --- a/js/tests/index.html +++ b/js/tests/index.html @@ -119,6 +119,7 @@ <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 index 000000000..372c6e3f7 --- /dev/null +++ b/js/tests/unit/util.js @@ -0,0 +1,57 @@ +$(function () { + 'use strict' + + QUnit.module('util') + + QUnit.test('Util.getSelectorFromElement should return the correct element', function (assert) { + assert.expect(2) + var $el = $('<div data-target="body"></div>').appendTo($('#qunit-fixture')) + assert.strictEqual(Util.getSelectorFromElement($el[0]), 'body') + + // not found element + var $el2 = $('<div data-target="#fakeDiv"></div>').appendTo($('#qunit-fixture')) + assert.strictEqual(Util.getSelectorFromElement($el2[0]), null) + }) + + QUnit.test('Util.typeCheckConfig should thrown an error when a bad config is passed', function (assert) { + assert.expect(1) + var namePlugin = 'collapse' + var defaultType = { + toggle : 'boolean', + parent : '(string|element)' + } + var config = { + toggle: true, + parent: 777 + } + + try { + Util.typeCheckConfig(namePlugin, config, defaultType) + } catch (e) { + assert.strictEqual(e.message, 'COLLAPSE: Option "parent" provided type "number" but expected type "(string|element)".') + } + }) + + QUnit.test('Util.isElement should check if we passed an element or not', function (assert) { + assert.expect(3) + var $div = $('<div id="test"></div>').appendTo($('#qunit-fixture')) + + assert.strictEqual(Util.isElement($div), 1) + assert.strictEqual(Util.isElement($div[0]), 1) + assert.strictEqual(typeof Util.isElement({}) === 'undefined', true) + }) + + QUnit.test('Util.getUID should generate a new id uniq', function (assert) { + assert.expect(2) + var id = Util.getUID('test') + var id2 = Util.getUID('test') + + assert.ok(id !== id2, id + ' !== ' + id2) + + id = Util.getUID('test') + $('<div id="' + id + '"></div>').appendTo($('#qunit-fixture')) + + id2 = Util.getUID('test') + assert.ok(id !== id2, id + ' !== ' + id2) + }) +}) |
