Skip to content

Commit

Permalink
Ensure SignatureRequestOriginal 'beforeunload' handler is bound (#7414)
Browse files Browse the repository at this point in the history
The 'beforeunload' handler was being bound to the module scope instead
of the instance scope, because the class was defined using prototypes
rather than the ES6 class syntax. The arrow functions were removed, and
the handler is now bound explicitly in the constructor.
  • Loading branch information
Gudahtt authored Nov 14, 2019
1 parent a34f1ea commit f5cec3e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ui/app/components/app/signature-request-original.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,10 @@ function SignatureRequest (props) {
this.state = {
selectedAccount: props.selectedAccount,
}
this._beforeUnload = this._beforeUnload.bind(this)
}

SignatureRequest.prototype._beforeUnload = (event) => {
SignatureRequest.prototype._beforeUnload = function (event) {
const { clearConfirmTransaction, cancel } = this.props
const { metricsEvent } = this.context
metricsEvent({
Expand All @@ -117,7 +118,7 @@ SignatureRequest.prototype._beforeUnload = (event) => {
cancel(event)
}

SignatureRequest.prototype._removeBeforeUnload = () => {
SignatureRequest.prototype._removeBeforeUnload = function () {
if (getEnvironmentType(window.location.href) === ENVIRONMENT_TYPE_NOTIFICATION) {
window.removeEventListener('beforeunload', this._beforeUnload)
}
Expand Down

0 comments on commit f5cec3e

Please sign in to comment.