Ensure SignatureRequestOriginal 'beforeunload' handler is bound (#7414)

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.
feature/default_network_editable
Mark Stacey 5 years ago committed by GitHub
parent a34f1eae53
commit f5cec3e6b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      ui/app/components/app/signature-request-original.js

@ -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({
@ -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)
}

Loading…
Cancel
Save