From: XhmikosR Date: Thu, 4 Jun 2020 07:41:47 +0000 (+0300) Subject: Backport #30936 X-Git-Tag: v4.5.1~43 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8bc6dcd280f096189214561b1f87f015cd2dcba1;p=thirdparty%2Fbootstrap.git Backport #30936 Add role="dialog" in modals via JavaScript --- diff --git a/js/src/modal.js b/js/src/modal.js index 7338ffd376..f898d0c465 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -265,6 +265,7 @@ class Modal { this._element.style.display = 'block' this._element.removeAttribute('aria-hidden') this._element.setAttribute('aria-modal', true) + this._element.setAttribute('role', 'dialog') if ($(this._dialog).hasClass(CLASS_NAME_SCROLLABLE) && modalBody) { modalBody.scrollTop = 0 @@ -344,6 +345,7 @@ class Modal { this._element.style.display = 'none' this._element.setAttribute('aria-hidden', true) this._element.removeAttribute('aria-modal') + this._element.removeAttribute('role') this._isTransitioning = false this._showBackdrop(() => { $(document.body).removeClass(CLASS_NAME_OPEN) diff --git a/js/tests/unit/modal.js b/js/tests/unit/modal.js index fefd84fceb..5434987d8b 100644 --- a/js/tests/unit/modal.js +++ b/js/tests/unit/modal.js @@ -297,6 +297,23 @@ $(function () { .bootstrapModal('show') }) + QUnit.test('should add role="dialog" attribute when shown, remove it again when hidden', function (assert) { + assert.expect(3) + var done = assert.async() + + $('