From: Johann-S Date: Fri, 13 Apr 2018 09:52:12 +0000 (+0200) Subject: fix issue related to Object.keys and Dropdown issue X-Git-Tag: v4.1.1~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ba10b63c9da3c0fab5611e8001e490af527b8c7a;p=thirdparty%2Fbootstrap.git fix issue related to Object.keys and Dropdown issue --- 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 = '
' + '' + '
' @@ -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 = '
' + '' + '
' @@ -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')