Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions js/src/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ class Modal {

this._element.style.display = 'block'
this._element.removeAttribute('aria-hidden')
this._element.setAttribute('aria-modal', true)
this._element.scrollTop = 0

if (transition) {
Expand Down Expand Up @@ -314,6 +315,7 @@ class Modal {
_hideModal() {
this._element.style.display = 'none'
this._element.setAttribute('aria-hidden', true)
this._element.removeAttribute('aria-modal')
this._isTransitioning = false
this._showBackdrop(() => {
$(document.body).removeClass(ClassName.OPEN)
Expand Down
17 changes: 17 additions & 0 deletions js/tests/unit/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,23 @@ $(function () {
.bootstrapModal('show')
})

QUnit.test('should add aria-modal attribute when shown, remove it again when hidden', function (assert) {
assert.expect(3)
var done = assert.async()

$('<div id="modal-test"/>')
.on('shown.bs.modal', function () {
assert.ok($('#modal-test').is('[aria-modal]'), 'aria-modal attribute added')
assert.strictEqual($('#modal-test').attr('aria-modal'), 'true', 'correct aria-modal="true" added')
$(this).bootstrapModal('hide')
})
.on('hidden.bs.modal', function () {
assert.notOk($('#modal-test').is('[aria-modal]'), 'aria-modal attribute removed')
done()
})
.bootstrapModal('show')
})

QUnit.test('should close reopened modal with [data-dismiss="modal"] click', function (assert) {
assert.expect(2)
var done = assert.async()
Expand Down