mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-22 13:13:03 +02:00
@@ -236,6 +236,7 @@ class Modal {
|
|||||||
|
|
||||||
_showElement(relatedTarget) {
|
_showElement(relatedTarget) {
|
||||||
const transition = $(this._element).hasClass(ClassName.FADE)
|
const transition = $(this._element).hasClass(ClassName.FADE)
|
||||||
|
const modalBody = this._dialog ? this._dialog.querySelector(Selector.MODAL_BODY) : null
|
||||||
|
|
||||||
if (!this._element.parentNode ||
|
if (!this._element.parentNode ||
|
||||||
this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
|
this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
|
||||||
@@ -247,8 +248,8 @@ class Modal {
|
|||||||
this._element.removeAttribute('aria-hidden')
|
this._element.removeAttribute('aria-hidden')
|
||||||
this._element.setAttribute('aria-modal', true)
|
this._element.setAttribute('aria-modal', true)
|
||||||
|
|
||||||
if ($(this._dialog).hasClass(ClassName.SCROLLABLE)) {
|
if ($(this._dialog).hasClass(ClassName.SCROLLABLE) && modalBody) {
|
||||||
this._dialog.querySelector(Selector.MODAL_BODY).scrollTop = 0
|
modalBody.scrollTop = 0
|
||||||
} else {
|
} else {
|
||||||
this._element.scrollTop = 0
|
this._element.scrollTop = 0
|
||||||
}
|
}
|
||||||
|
@@ -812,4 +812,25 @@ $(function () {
|
|||||||
})
|
})
|
||||||
.bootstrapModal('show')
|
.bootstrapModal('show')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
QUnit.test('should set .modal\'s scroll top to 0 if .modal-dialog-scrollable and modal body do not exists', function (assert) {
|
||||||
|
assert.expect(1)
|
||||||
|
var done = assert.async()
|
||||||
|
|
||||||
|
var $modal = $([
|
||||||
|
'<div id="modal-test">',
|
||||||
|
' <div class="modal-dialog modal-dialog-scrollable">',
|
||||||
|
' <div class="modal-content">',
|
||||||
|
' </div>',
|
||||||
|
' </div>',
|
||||||
|
'</div>'
|
||||||
|
].join('')).appendTo('#qunit-fixture')
|
||||||
|
|
||||||
|
|
||||||
|
$modal.on('shown.bs.modal', function () {
|
||||||
|
assert.strictEqual($modal.scrollTop(), 0)
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
.bootstrapModal('show')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user