0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-01-28 20:52:21 +01:00

fix issue related to Object.keys and Dropdown issue

This commit is contained in:
Johann-S 2018-04-13 11:52:12 +02:00
parent c3caf7ee4e
commit ba10b63c9d
5 changed files with 39 additions and 39 deletions

View 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)) {

View File

@ -500,7 +500,7 @@ const Modal = (($) => {
const _config = {
...Default,
...$(this).data(),
...typeof config === 'object' && config
...typeof config === 'object' && config ? config : {}
}
if (!data) {

View File

@ -165,7 +165,7 @@ const ScrollSpy = (($) => {
_getConfig(config) {
config = {
...Default,
...config
...typeof config === 'object' && config ? config : {}
}
if (typeof config.target !== 'string') {

View 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') {

View File

@ -544,6 +544,41 @@ $(function () {
$dropdown.trigger('click')
})
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 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>'
var $dropdown = $(dropdownHTML)
.appendTo('#qunit-fixture')
.find('[data-toggle="dropdown"]')
.bootstrapDropdown()
$dropdown
.parent('.dropdown')
.on('shown.bs.dropdown', function () {
assert.ok(true, 'shown was fired')
$dropdown.trigger($.Event('keydown', {
which: 40
}))
$dropdown.trigger($.Event('keydown', {
which: 40
}))
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 focus next/previous element when using keyboard navigation', function (assert) {
assert.expect(4)
var done = assert.async()
@ -584,41 +619,6 @@ $(function () {
$dropdown.trigger('click')
})
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 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>'
var $dropdown = $(dropdownHTML)
.appendTo('#qunit-fixture')
.find('[data-toggle="dropdown"]')
.bootstrapDropdown()
$dropdown
.parent('.dropdown')
.on('shown.bs.dropdown', function () {
assert.ok(true, 'shown was fired')
$dropdown.trigger($.Event('keydown', {
which: 40
}))
assert.ok($(document.activeElement).is($('#item1')), '#item1 is focused')
$dropdown.trigger($.Event('keydown', {
which: 40
}))
assert.ok($(document.activeElement).is($('#item1')), '#item1 is still focused')
done()
})
$dropdown.trigger('click')
})
QUnit.test('should not close the dropdown if the user clicks on a text field', function (assert) {
assert.expect(2)
var done = assert.async()