File tree 2 files changed +37
-0
lines changed
2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -132,6 +132,12 @@ const Toast = (($) => {
132
132
133
133
dispose ( ) {
134
134
clearTimeout ( this . _timeout )
135
+ this . _timeout = null
136
+
137
+ if ( this . _element . classList . contains ( ClassName . SHOW ) ) {
138
+ this . _element . classList . remove ( ClassName . SHOW )
139
+ }
140
+
135
141
$ . removeData ( this . _element , DATA_KEY )
136
142
this . _element = null
137
143
this . _config = null
Original file line number Diff line number Diff line change @@ -153,6 +153,37 @@ $(function () {
153
153
assert . ok ( typeof $toast . data ( 'bs.toast' ) === 'undefined' )
154
154
} )
155
155
156
+ QUnit . test ( 'should allow to destroy toast and hide it before that' , function ( assert ) {
157
+ assert . expect ( 4 )
158
+ var done = assert . async ( )
159
+
160
+ var toastHtml =
161
+ '<div class="toast" data-delay="0" data-autohide="false">' +
162
+ '<div class="toast-body">' +
163
+ 'a simple toast' +
164
+ '</div>' +
165
+ '</div>'
166
+
167
+ var $toast = $ ( toastHtml )
168
+ . bootstrapToast ( )
169
+ . appendTo ( $ ( '#qunit-fixture' ) )
170
+
171
+ $toast . one ( 'shown.bs.toast' , function ( ) {
172
+ setTimeout ( function ( ) {
173
+ assert . ok ( $toast . hasClass ( 'show' ) )
174
+ assert . ok ( typeof $toast . data ( 'bs.toast' ) !== 'undefined' )
175
+
176
+ $toast . bootstrapToast ( 'dispose' )
177
+
178
+ assert . ok ( typeof $toast . data ( 'bs.toast' ) === 'undefined' )
179
+ assert . ok ( $toast . hasClass ( 'show' ) === false )
180
+
181
+ done ( )
182
+ } , 1 )
183
+ } )
184
+ . bootstrapToast ( 'show' )
185
+ } )
186
+
156
187
QUnit . test ( 'should allow to pass delay object in html' , function ( assert ) {
157
188
assert . expect ( 1 )
158
189
var done = assert . async ( )
You can’t perform that action at this time.
0 commit comments