Skip to content

Commit

Permalink
Bind to beforeunload instead of unload to fix firefox issues
Browse files Browse the repository at this point in the history
Some firefox users reported odd connection issues caused by an
unload listener
ref: phoenixframework/phoenix_live_view#1425
  • Loading branch information
chrismccord committed May 10, 2021
1 parent 23c1013 commit 196e11b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions assets/js/phoenix.js
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ export class Socket {
this.decode = this.defaultDecoder
}
if(phxWindow && phxWindow.addEventListener){
phxWindow.addEventListener("unload", e => {
phxWindow.addEventListener("beforeunload", e => {
if(this.conn){
this.unloaded = true
this.abnormalClose("unloaded")
Expand Down Expand Up @@ -1625,4 +1625,4 @@ class Timer {
this.callback()
}, this.timerCalc(this.tries + 1))
}
}
}
Loading

0 comments on commit 196e11b

Please # to comment.