mirror of
https://github.com/twbs/bootstrap.git
synced 2025-01-29 21:52:22 +01:00
fix issue related to Object.keys and Dropdown issue
This commit is contained in:
parent
c3caf7ee4e
commit
ba10b63c9d
@ -331,7 +331,7 @@ const Collapse = (($) => {
|
|||||||
const _config = {
|
const _config = {
|
||||||
...Default,
|
...Default,
|
||||||
...$this.data(),
|
...$this.data(),
|
||||||
...typeof config === 'object' && config
|
...typeof config === 'object' && config ? config : {}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!data && _config.toggle && /show|hide/.test(config)) {
|
if (!data && _config.toggle && /show|hide/.test(config)) {
|
||||||
|
@ -500,7 +500,7 @@ const Modal = (($) => {
|
|||||||
const _config = {
|
const _config = {
|
||||||
...Default,
|
...Default,
|
||||||
...$(this).data(),
|
...$(this).data(),
|
||||||
...typeof config === 'object' && config
|
...typeof config === 'object' && config ? config : {}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
|
@ -165,7 +165,7 @@ const ScrollSpy = (($) => {
|
|||||||
_getConfig(config) {
|
_getConfig(config) {
|
||||||
config = {
|
config = {
|
||||||
...Default,
|
...Default,
|
||||||
...config
|
...typeof config === 'object' && config ? config : {}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof config.target !== 'string') {
|
if (typeof config.target !== 'string') {
|
||||||
|
@ -611,7 +611,7 @@ const Tooltip = (($) => {
|
|||||||
config = {
|
config = {
|
||||||
...this.constructor.Default,
|
...this.constructor.Default,
|
||||||
...$(this.element).data(),
|
...$(this.element).data(),
|
||||||
...config
|
...typeof config === 'object' && config ? config : {}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof config.delay === 'number') {
|
if (typeof config.delay === 'number') {
|
||||||
|
@ -544,6 +544,41 @@ $(function () {
|
|||||||
$dropdown.trigger('click')
|
$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) {
|
QUnit.test('should focus next/previous element when using keyboard navigation', function (assert) {
|
||||||
assert.expect(4)
|
assert.expect(4)
|
||||||
var done = assert.async()
|
var done = assert.async()
|
||||||
@ -584,41 +619,6 @@ $(function () {
|
|||||||
$dropdown.trigger('click')
|
$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) {
|
QUnit.test('should not close the dropdown if the user clicks on a text field', function (assert) {
|
||||||
assert.expect(2)
|
assert.expect(2)
|
||||||
var done = assert.async()
|
var done = assert.async()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user