Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow to override default toast options #28186

Merged
merged 2 commits into from
Feb 6, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions js/src/toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ class Toast {
return DefaultType
}

static get Default() {
return Default
}

// Public

show() {
Expand Down
20 changes: 20 additions & 0 deletions js/tests/unit/toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})