File tree 3 files changed +4
-4
lines changed
3 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -291,7 +291,7 @@ export class Client {
291
291
292
292
this . onUnload = this . onUnload . bind ( this )
293
293
if ( typeof window !== 'undefined' && window . addEventListener ) {
294
- window . addEventListener ( 'unload ' , this . onUnload )
294
+ window . addEventListener ( 'pagehide ' , this . onUnload )
295
295
}
296
296
297
297
this . processing = { }
@@ -347,7 +347,7 @@ export class Client {
347
347
this . node . destroy ( )
348
348
clearInterval ( this . pinging )
349
349
if ( typeof window !== 'undefined' && window . removeEventListener ) {
350
- window . removeEventListener ( 'unload ' , this . onUnload )
350
+ window . removeEventListener ( 'pagehide ' , this . onUnload )
351
351
}
352
352
}
353
353
Original file line number Diff line number Diff line change @@ -383,7 +383,7 @@ it('cleans own actions on unload', async () => {
383
383
{ type : 'A' } ,
384
384
{ reasons : [ 'tab' + client . tabId ] , tab : client . tabId }
385
385
)
386
- window . dispatchEvent ( new Event ( 'unload ' ) )
386
+ window . dispatchEvent ( new Event ( 'pagehide ' ) )
387
387
await delay ( 10 )
388
388
expect ( client . log . actions ( ) ) . toHaveLength ( 0 )
389
389
expect ( localStorage . getItem ( 'test:tab:' + client . tabId ) ) . toBeNull ( )
Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ export class CrossTabClient extends Client {
70
70
71
71
if ( typeof window !== 'undefined' && window . addEventListener ) {
72
72
window . addEventListener ( 'storage' , e => this . onStorage ( e ) )
73
- window . addEventListener ( 'unload ' , e => this . onUnload ( e ) )
73
+ window . addEventListener ( 'pagehide ' , e => this . onUnload ( e ) )
74
74
}
75
75
76
76
if ( this . isLocalStorage ) {
You can’t perform that action at this time.
0 commit comments