mirror of
https://github.com/twbs/bootstrap.git
synced 2024-12-01 13:24:25 +01:00
parent
41b8ce278b
commit
bab999701c
@ -436,6 +436,10 @@ class Dropdown {
|
||||
|
||||
toggles[i].setAttribute('aria-expanded', 'false')
|
||||
|
||||
if (context._popper) {
|
||||
context._popper.destroy()
|
||||
}
|
||||
|
||||
$(dropdownMenu).removeClass(ClassName.SHOW)
|
||||
$(parent)
|
||||
.removeClass(ClassName.SHOW)
|
||||
|
@ -799,7 +799,7 @@ $(function () {
|
||||
.parent('.dropdown')
|
||||
.on('shown.bs.dropdown', function () {
|
||||
// Forcibly focus first item
|
||||
$item.focus()
|
||||
$item[0].focus()
|
||||
assert.ok($(document.activeElement)[0] === $item[0], 'menu item initial focus set')
|
||||
|
||||
// Key escape
|
||||
@ -1506,4 +1506,48 @@ $(function () {
|
||||
|
||||
assert.strictEqual(popperConfig.placement, 'left')
|
||||
})
|
||||
|
||||
QUnit.test('should destroy old popper references on toggle', function (assert) {
|
||||
assert.expect(3)
|
||||
var done = assert.async()
|
||||
|
||||
var fixtureHtml = [
|
||||
'<div class="first dropdown">',
|
||||
' <button href="#" class="firstBtn btn" data-toggle="dropdown" aria-expanded="false">Dropdown</button>',
|
||||
' <div class="dropdown-menu">',
|
||||
' <a class="dropdown-item" href="#">Secondary link</a>',
|
||||
' </div>',
|
||||
'</div>',
|
||||
'<div class="second dropdown">',
|
||||
' <button href="#" class="secondBtn btn" data-toggle="dropdown" aria-expanded="false">Dropdown</button>',
|
||||
' <div class="dropdown-menu">',
|
||||
' <a class="dropdown-item" href="#">Secondary link</a>',
|
||||
' </div>',
|
||||
'</div>'
|
||||
].join('')
|
||||
|
||||
$(fixtureHtml).appendTo('#qunit-fixture')
|
||||
|
||||
var $btnDropdown1 = $('.firstBtn').bootstrapDropdown()
|
||||
var $btnDropdown2 = $('.secondBtn').bootstrapDropdown()
|
||||
var $firstDropdownEl = $('.first')
|
||||
var $secondDropdownEl = $('.second')
|
||||
var dropdown1 = $btnDropdown1.data('bs.dropdown')
|
||||
var dropdown2 = $btnDropdown2.data('bs.dropdown')
|
||||
var spyPopper
|
||||
|
||||
$firstDropdownEl.one('shown.bs.dropdown', function () {
|
||||
assert.strictEqual($firstDropdownEl.hasClass('show'), true)
|
||||
spyPopper = sinon.spy(dropdown1._popper, 'destroy')
|
||||
dropdown2.toggle()
|
||||
})
|
||||
|
||||
$secondDropdownEl.one('shown.bs.dropdown', function () {
|
||||
assert.strictEqual($secondDropdownEl.hasClass('show'), true)
|
||||
assert.ok(spyPopper.called)
|
||||
done()
|
||||
})
|
||||
|
||||
dropdown1.toggle()
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user