File tree Expand file tree Collapse file tree 1 file changed +6
-15
lines changed
Expand file tree Collapse file tree 1 file changed +6
-15
lines changed Original file line number Diff line number Diff line change 1414 console . log ( `SimpleToast(v${ localToast . versionString } ): Publicized` ) ;
1515 }
1616} ) ( this , ( ) => {
17- const version = buildVersion ( 1 , 13 , 0 ) ;
17+ const version = buildVersion ( 2 , 0 , 0 ) ;
1818 const style = {
1919 root : {
2020 display : 'flex' ,
121121 pending += 1 ;
122122 return ;
123123 }
124- toast . timedout ( ) ;
124+ toast . close ( 'timeout' ) ;
125125 } ) ;
126126 if ( pending ) {
127127 startTimeout ( ) ;
164164 applyCSS ( fel , css . footer ) ;
165165 fel . innerHTML = footer ;
166166 }
167-
168- let closeType = 'unknown' ;
167+
169168 const safeToast = { } ;
170169 const toast = {
171170 setText : ( newText ) => {
172171 if ( ! newText || ! toast . exists ( ) ) return ;
173172 body . innerHTML = newText ;
174173 } ,
175174 exists : ( ) => toasts . has ( id ) ,
176- close : ( ) => {
175+ close : ( closeType ) => {
177176 if ( ! toast . exists ( ) ) return ;
178177 root . removeChild ( el ) ;
179178 toasts . delete ( id ) ;
180179 if ( typeof onClose === 'function' ) {
181- onClose . call ( safeToast , closeType , safeToast ) ;
180+ onClose . call ( safeToast , closeType || 'unknown' , safeToast ) ;
182181 }
183182 } ,
184- timedout : ( ) => {
185- closeType = 'timeout' ;
186- toast . close ( ) ;
187- } ,
188- closed : ( ) => {
189- closeType = 'dismissed' ;
190- toast . close ( ) ;
191- } ,
192183 } ;
193184 if ( timeout ) {
194185 toast . timeout = Date . now ( ) + timeout ;
229220 el . insertBefore ( elb , fel ) ;
230221 } ) ;
231222 }
232- el . addEventListener ( 'click' , toast . closed ) ;
223+ el . addEventListener ( 'click' , toast . close . bind ( null , 'dismissed' ) ) ;
233224
234225 root . appendChild ( el ) ;
235226 toasts . set ( id , toast ) ;
You can’t perform that action at this time.
0 commit comments