mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
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.
This commit is contained in:
parent
a34f1eae53
commit
f5cec3e6b7
@ -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…
Reference in New Issue
Block a user