diff --git a/js/src/dropdown.js b/js/src/dropdown.js index 777d45f7c396..6baa7171ed9d 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -1,3 +1,5 @@ +/* global Popper */ + import Util from './util' @@ -64,7 +66,7 @@ const Dropdown = (($) => { const Default = { placement : 'bottom', - offset : {} + offset : 0 } const DefaultType = { @@ -143,7 +145,7 @@ const Dropdown = (($) => { placement : context._config.placement, modifiers : { offset : { - offset : this.config.offset + offset : context._config.offset } } }) @@ -204,7 +206,7 @@ const Dropdown = (($) => { _getMenuElement() { if (!this._menu) { - let parent = Dropdown._getParentFromElement(this._element) + const parent = Dropdown._getParentFromElement(this._element) this._menu = $(parent).find(Selector.MENU)[0] } return this._menu @@ -215,7 +217,7 @@ const Dropdown = (($) => { static _jQueryInterface(config) { return this.each(function () { let data = $(this).data(DATA_KEY) - let _config = typeof config === 'object' ? config : null + const _config = typeof config === 'object' ? config : null if (!data) { data = new Dropdown(this, _config) @@ -240,7 +242,7 @@ const Dropdown = (($) => { const toggles = $.makeArray($(Selector.DATA_TOGGLE)) for (let i = 0; i < toggles.length; i++) { const parent = Dropdown._getParentFromElement(toggles[i]) - let context = $(toggles[i]).data(DATA_KEY) + const context = $(toggles[i]).data(DATA_KEY) const relatedTarget = { relatedTarget : toggles[i] } @@ -249,7 +251,7 @@ const Dropdown = (($) => { continue } - let dropdownMenu = context._menu + const dropdownMenu = context._menu if (!$(parent).hasClass(ClassName.SHOW)) { continue } diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 6205b7d182f3..fd8b8ad59d4c 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -47,7 +47,7 @@ const Tooltip = (($) => { html : false, selector : false, placement : 'top', - offset : {}, + offset : 0, container : false } diff --git a/js/tests/unit/dropdown.js b/js/tests/unit/dropdown.js index a15eb52450d6..1dd675b0b685 100644 --- a/js/tests/unit/dropdown.js +++ b/js/tests/unit/dropdown.js @@ -275,20 +275,20 @@ $(function () { $first.parent('.dropdown') .on('shown.bs.dropdown', function () { assert.strictEqual($first.parents('.show').length, 1, '"show" class added on click') - assert.strictEqual($('#qunit-fixture .show').length, 1, 'only one dropdown is shown') + assert.strictEqual($('#qunit-fixture .dropdown-menu.show').length, 1, 'only one dropdown is shown') $(document.body).trigger('click') }).on('hidden.bs.dropdown', function () { - assert.strictEqual($('#qunit-fixture .show').length, 0, '"show" class removed') + assert.strictEqual($('#qunit-fixture .dropdown-menu.show').length, 0, '"show" class removed') $last.trigger('click') }) $last.parent('.btn-group') .on('shown.bs.dropdown', function () { assert.strictEqual($last.parent('.show').length, 1, '"show" class added on click') - assert.strictEqual($('#qunit-fixture .show').length, 1, 'only one dropdown is shown') + assert.strictEqual($('#qunit-fixture .dropdown-menu.show').length, 1, 'only one dropdown is shown') $(document.body).trigger('click') }).on('hidden.bs.dropdown', function () { - assert.strictEqual($('#qunit-fixture .show').length, 0, '"show" class removed') + assert.strictEqual($('#qunit-fixture .dropdown-menu.show').length, 0, '"show" class removed') done() }) $first.trigger('click') @@ -321,24 +321,24 @@ $(function () { $first.parent('.dropdown') .on('shown.bs.dropdown', function () { assert.strictEqual($first.parents('.show').length, 1, '"show" class added on click') - assert.strictEqual($('#qunit-fixture .show').length, 1, 'only one dropdown is shown') + assert.strictEqual($('#qunit-fixture .dropdown-menu.show').length, 1, 'only one dropdown is shown') var e = $.Event('keyup') e.which = 9 // Tab $(document.body).trigger(e) }).on('hidden.bs.dropdown', function () { - assert.strictEqual($('#qunit-fixture .show').length, 0, '"show" class removed') + assert.strictEqual($('#qunit-fixture .dropdown-menu.show').length, 0, '"show" class removed') $last.trigger('click') }) $last.parent('.btn-group') .on('shown.bs.dropdown', function () { assert.strictEqual($last.parent('.show').length, 1, '"show" class added on click') - assert.strictEqual($('#qunit-fixture .show').length, 1, 'only one dropdown is shown') + assert.strictEqual($('#qunit-fixture .dropdown-menu.show').length, 1, 'only one dropdown is shown') var e = $.Event('keyup') e.which = 9 // Tab $(document.body).trigger(e) }).on('hidden.bs.dropdown', function () { - assert.strictEqual($('#qunit-fixture .show').length, 0, '"show" class removed') + assert.strictEqual($('#qunit-fixture .dropdown-menu.show').length, 0, '"show" class removed') done() }) $first.trigger('click') @@ -552,7 +552,7 @@ $(function () { }) QUnit.test('should not close the dropdown if the user clicks on a text field', function (assert) { - assert.expect(1) + assert.expect(2) var done = assert.async() var dropdownHTML = '