From fcc6baf0d11f49dc4de306b09ed1013870b222ea Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Thu, 14 Nov 2019 14:28:40 -0400 Subject: [PATCH] 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. --- ui/app/components/app/signature-request-original.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ui/app/components/app/signature-request-original.js b/ui/app/components/app/signature-request-original.js index 60b910eb0..e23d724cb 100644 --- a/ui/app/components/app/signature-request-original.js +++ b/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) }