Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohann-S <johann.servoire@gmail.com>2019-02-06 16:19:04 +0300
committerXhmikosR <xhmikosr@gmail.com>2019-02-06 16:19:04 +0300
commit3c49467224cc7f37ce56ce9c287de8f169efd7b3 (patch)
treeedc8a8d4a7536169e06947980f3e886113b2b0c7
parent58470c0ac508df1b03e93faf5c2ff0e11fa3c078 (diff)
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 98be2a4187..02596e9dad 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 e6bd6be1ee..2081693ebc 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)
+ })
})