aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohann-S <[email protected]>2019-02-06 14:19:04 +0100
committerXhmikosR <[email protected]>2019-02-06 15:19:04 +0200
commit3c49467224cc7f37ce56ce9c287de8f169efd7b3 (patch)
treeedc8a8d4a7536169e06947980f3e886113b2b0c7
parent58470c0ac508df1b03e93faf5c2ff0e11fa3c078 (diff)
downloadbootstrap-3c49467224cc7f37ce56ce9c287de8f169efd7b3.tar.xz
bootstrap-3c49467224cc7f37ce56ce9c287de8f169efd7b3.zip
allow to override default toast options (#28186)
-rw-r--r--js/src/toast.js4
-rw-r--r--js/tests/unit/toast.js20
2 files changed, 24 insertions, 0 deletions
diff --git a/js/src/toast.js b/js/src/toast.js
index 98be2a418..02596e9da 100644
--- a/js/src/toast.js
+++ b/js/src/toast.js
@@ -75,6 +75,10 @@ class Toast {
return DefaultType
}
+ static get Default() {
+ return Default
+ }
+
// Public
show() {
diff --git a/js/tests/unit/toast.js b/js/tests/unit/toast.js
index e6bd6be1e..2081693eb 100644
--- a/js/tests/unit/toast.js
+++ b/js/tests/unit/toast.js
@@ -236,4 +236,24 @@ $(function () {
})
.bootstrapToast('show')
})
+
+ QUnit.test('should expose default setting to allow to override them', function (assert) {
+ assert.expect(1)
+
+ var defaultDelay = 1000
+ Toast.Default.delay = defaultDelay
+
+ var toastHtml =
+ '<div class="toast" data-autohide="false" data-animation="false">' +
+ '<button type="button" class="ml-2 mb-1 close" data-dismiss="toast">' +
+ 'close' +
+ '</button>' +
+ '</div>'
+
+ var $toast = $(toastHtml)
+ .bootstrapToast()
+
+ var toast = $toast.data('bs.toast')
+ assert.strictEqual(toast._config.delay, defaultDelay)
+ })
})