Skip to content

Commit 196e11b

Browse files
committed
Bind to beforeunload instead of unload to fix firefox issues
Some firefox users reported odd connection issues caused by an unload listener ref: phoenixframework/phoenix_live_view#1425
1 parent 23c1013 commit 196e11b

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

assets/js/phoenix.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ export class Socket {
868868
this.decode = this.defaultDecoder
869869
}
870870
if(phxWindow && phxWindow.addEventListener){
871-
phxWindow.addEventListener("unload", e => {
871+
phxWindow.addEventListener("beforeunload", e => {
872872
if(this.conn){
873873
this.unloaded = true
874874
this.abnormalClose("unloaded")
@@ -1625,4 +1625,4 @@ class Timer {
16251625
this.callback()
16261626
}, this.timerCalc(this.tries + 1))
16271627
}
1628-
}
1628+
}

0 commit comments

Comments
 (0)