diff --git a/js/src/toast.js b/js/src/toast.js index 1e70e091f2..878ffe0296 100644 --- a/js/src/toast.js +++ b/js/src/toast.js @@ -38,16 +38,13 @@ const Toast = (($) => { const DefaultType = { animation : 'boolean', autohide : 'boolean', - delay : '(number|object)' + delay : 'number' } const Default = { animation : true, autohide : true, - delay : { - show: 0, - hide: 500 - } + delay : 500 } const Selector = { @@ -95,19 +92,16 @@ const Toast = (($) => { } } - this._timeout = setTimeout(() => { - this._element.classList.add(ClassName.SHOW) + this._element.classList.add(ClassName.SHOW) + if (this._config.animation) { + const transitionDuration = Util.getTransitionDurationFromElement(this._element) - if (this._config.animation) { - const transitionDuration = Util.getTransitionDurationFromElement(this._element) - - $(this._element) - .one(Util.TRANSITION_END, complete) - .emulateTransitionEnd(transitionDuration) - } else { - complete() - } - }, this._config.delay.show) + $(this._element) + .one(Util.TRANSITION_END, complete) + .emulateTransitionEnd(transitionDuration) + } else { + complete() + } } hide(withoutTimeout) { @@ -122,7 +116,7 @@ const Toast = (($) => { } else { this._timeout = setTimeout(() => { this._close() - }, this._config.delay.hide) + }, this._config.delay) } } @@ -150,13 +144,6 @@ const Toast = (($) => { ...typeof config === 'object' && config ? config : {} } - if (typeof config.delay === 'number') { - config.delay = { - show: config.delay, - hide: config.delay - } - } - Util.typeCheckConfig( NAME, config, diff --git a/js/tests/unit/toast.js b/js/tests/unit/toast.js index d9c5e1fb6e..e6bd6be1ee 100644 --- a/js/tests/unit/toast.js +++ b/js/tests/unit/toast.js @@ -184,28 +184,6 @@ $(function () { .bootstrapToast('show') }) - QUnit.test('should allow to pass delay object in html', function (assert) { - assert.expect(1) - var done = assert.async() - - var toastHtml = - '