]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
fix issue related to Object.keys and Dropdown issue
authorJohann-S <johann.servoire@gmail.com>
Fri, 13 Apr 2018 09:52:12 +0000 (11:52 +0200)
committerJohann-S <johann.servoire@gmail.com>
Fri, 13 Apr 2018 16:59:30 +0000 (18:59 +0200)
js/src/collapse.js
js/src/modal.js
js/src/scrollspy.js
js/src/tooltip.js
js/tests/unit/dropdown.js

index c3b3599ecc730db49c659009debae4dcf93a6635..e22cf0b7ab6818a091c9c90e03910772f7183230 100644 (file)
@@ -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)) {
index 1df41526669f361d080e7f2308dcf42ff8bbbbb5..e3de68b8fe7d17c1f12af0709ff8602ee7e7dc1a 100644 (file)
@@ -500,7 +500,7 @@ const Modal = (($) => {
         const _config = {
           ...Default,
           ...$(this).data(),
-          ...typeof config === 'object' && config
+          ...typeof config === 'object' && config ? config : {}
         }
 
         if (!data) {
index 1c46940f53f5c8075367489c285a5dd9901b3e6c..d8cf69473b98ba0f9a48461e23ae4755bbf4eedd 100644 (file)
@@ -165,7 +165,7 @@ const ScrollSpy = (($) => {
     _getConfig(config) {
       config = {
         ...Default,
-        ...config
+        ...typeof config === 'object' && config ? config : {}
       }
 
       if (typeof config.target !== 'string') {
index f751ee3c94c1e8427c56b1650ae29b857eb47c90..59c26897c99518aa836b29f250ef906a58083058 100644 (file)
@@ -611,7 +611,7 @@ const Tooltip = (($) => {
       config = {
         ...this.constructor.Default,
         ...$(this.element).data(),
-        ...config
+        ...typeof config === 'object' && config ? config : {}
       }
 
       if (typeof config.delay === 'number') {
index 726655e9cccee8b51ef915decc0d38fb9e37c15b..f87c65bea03152b801355348b1ae847deeb49952 100644 (file)
@@ -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')