diff options
author | Johann-S <johann.servoire@gmail.com> | 2018-04-13 12:52:12 +0300 |
---|---|---|
committer | Johann-S <johann.servoire@gmail.com> | 2018-04-13 19:59:30 +0300 |
commit | ba10b63c9da3c0fab5611e8001e490af527b8c7a (patch) | |
tree | 1f2232242d0c22509c99e4e3c298e7b351cecf91 | |
parent | c3caf7ee4e1e6403169ec36e1b1bef36f894c16a (diff) |
fix issue related to Object.keys and Dropdown issue
-rw-r--r-- | js/src/collapse.js | 2 | ||||
-rw-r--r-- | js/src/modal.js | 2 | ||||
-rw-r--r-- | js/src/scrollspy.js | 2 | ||||
-rw-r--r-- | js/src/tooltip.js | 2 | ||||
-rw-r--r-- | js/tests/unit/dropdown.js | 42 |
5 files changed, 25 insertions, 25 deletions
diff --git a/js/src/collapse.js b/js/src/collapse.js index c3b3599ecc..e22cf0b7ab 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -331,7 +331,7 @@ const Collapse = (($) => { const _config = { ...Default, ...$this.data(), - ...typeof config === 'object' && config + ...typeof config === 'object' && config ? config : {} } if (!data && _config.toggle && /show|hide/.test(config)) { diff --git a/js/src/modal.js b/js/src/modal.js index 1df4152666..e3de68b8fe 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -500,7 +500,7 @@ const Modal = (($) => { const _config = { ...Default, ...$(this).data(), - ...typeof config === 'object' && config + ...typeof config === 'object' && config ? config : {} } if (!data) { diff --git a/js/src/scrollspy.js b/js/src/scrollspy.js index 1c46940f53..d8cf69473b 100644 --- a/js/src/scrollspy.js +++ b/js/src/scrollspy.js @@ -165,7 +165,7 @@ const ScrollSpy = (($) => { _getConfig(config) { config = { ...Default, - ...config + ...typeof config === 'object' && config ? config : {} } if (typeof config.target !== 'string') { diff --git a/js/src/tooltip.js b/js/src/tooltip.js index f751ee3c94..59c26897c9 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -611,7 +611,7 @@ const Tooltip = (($) => { config = { ...this.constructor.Default, ...$(this.element).data(), - ...config + ...typeof config === 'object' && config ? config : {} } if (typeof config.delay === 'number') { diff --git a/js/tests/unit/dropdown.js b/js/tests/unit/dropdown.js index 726655e9cc..f87c65bea0 100644 --- a/js/tests/unit/dropdown.js +++ b/js/tests/unit/dropdown.js @@ -544,15 +544,16 @@ $(function () { $dropdown.trigger('click') }) - QUnit.test('should focus next/previous element when using keyboard navigation', function (assert) { - assert.expect(4) + QUnit.test('should skip disabled element when using keyboard navigation', function (assert) { + assert.expect(3) var done = assert.async() var dropdownHTML = '<div class="tabs">' + '<div class="dropdown">' + '<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>' + '<div class="dropdown-menu">' + - '<a id="item1" class="dropdown-item" href="#">A link</a>' + - '<a id="item2" class="dropdown-item" href="#">Another link</a>' + + '<a class="dropdown-item disabled" href="#">Disabled link</a>' + + '<button class="dropdown-item" type="button" disabled>Disabled button</button>' + + '<a id="item1" class="dropdown-item" href="#">Another link</a>' + '</div>' + '</div>' + '</div>' @@ -568,32 +569,25 @@ $(function () { $dropdown.trigger($.Event('keydown', { which: 40 })) - assert.ok($(document.activeElement).is($('#item1')), 'item1 is focused') - - $(document.activeElement).trigger($.Event('keydown', { + $dropdown.trigger($.Event('keydown', { which: 40 })) - assert.ok($(document.activeElement).is($('#item2')), 'item2 is focused') - - $(document.activeElement).trigger($.Event('keydown', { - which: 38 - })) - assert.ok($(document.activeElement).is($('#item1')), 'item1 is focused') + assert.ok(!$(document.activeElement).is('.disabled'), '.disabled is not focused') + assert.ok(!$(document.activeElement).is(':disabled'), ':disabled is not focused') done() }) $dropdown.trigger('click') }) - QUnit.test('should skip disabled element when using keyboard navigation', function (assert) { - assert.expect(3) + QUnit.test('should focus next/previous element when using keyboard navigation', function (assert) { + assert.expect(4) var done = assert.async() var dropdownHTML = '<div class="tabs">' + '<div class="dropdown">' + '<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>' + '<div class="dropdown-menu">' + - '<a class="dropdown-item disabled" href="#">Disabled link</a>' + - '<button class="dropdown-item" type="button" disabled>Disabled button</button>' + - '<a id="item1" class="dropdown-item" href="#">Another link</a>' + + '<a id="item1" class="dropdown-item" href="#">A link</a>' + + '<a id="item2" class="dropdown-item" href="#">Another link</a>' + '</div>' + '</div>' + '</div>' @@ -609,11 +603,17 @@ $(function () { $dropdown.trigger($.Event('keydown', { which: 40 })) - assert.ok($(document.activeElement).is($('#item1')), '#item1 is focused') - $dropdown.trigger($.Event('keydown', { + assert.ok($(document.activeElement).is($('#item1')), 'item1 is focused') + + $(document.activeElement).trigger($.Event('keydown', { which: 40 })) - assert.ok($(document.activeElement).is($('#item1')), '#item1 is still focused') + assert.ok($(document.activeElement).is($('#item2')), 'item2 is focused') + + $(document.activeElement).trigger($.Event('keydown', { + which: 38 + })) + assert.ok($(document.activeElement).is($('#item1')), 'item1 is focused') done() }) $dropdown.trigger('click') |