Skip to content

Commit

Permalink
Ensure SignatureRequestOriginal 'beforeunload' handler is bound
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 committed Nov 13, 2019
1 parent 33d6abf commit 52b7914
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 52b7914

Please sign in to comment.