aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGraham Kaemmer <gkaemmer@users.noreply.github.com>2019-02-19 05:07:58 +0800
committerPaul Bouchon <mail@bitpshr.net>2019-02-19 05:07:58 +0800
commit89c43534082b920f68503eddc1dd3cc8f16aeb17 (patch)
tree7344503f5e1d5c257692193ecb56e59491093601
parentb58a9bd2028e5719f4b3b8ed3a9088f4145fb6e5 (diff)
downloadtangerine-wallet-browser-89c43534082b920f68503eddc1dd3cc8f16aeb17.tar
tangerine-wallet-browser-89c43534082b920f68503eddc1dd3cc8f16aeb17.tar.gz
tangerine-wallet-browser-89c43534082b920f68503eddc1dd3cc8f16aeb17.tar.bz2
tangerine-wallet-browser-89c43534082b920f68503eddc1dd3cc8f16aeb17.tar.lz
tangerine-wallet-browser-89c43534082b920f68503eddc1dd3cc8f16aeb17.tar.xz
tangerine-wallet-browser-89c43534082b920f68503eddc1dd3cc8f16aeb17.tar.zst
tangerine-wallet-browser-89c43534082b920f68503eddc1dd3cc8f16aeb17.zip
Fix inpage.js event handler memory leak (#6177)
Fixes #6176
-rw-r--r--app/scripts/inpage.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/app/scripts/inpage.js b/app/scripts/inpage.js
index fb2a84d1a..ae5a375b0 100644
--- a/app/scripts/inpage.js
+++ b/app/scripts/inpage.js
@@ -29,12 +29,13 @@ console.warn('ATTENTION: In an effort to improve user privacy, MetaMask ' +
* @param {Function} handler - event handler
* @param {boolean} remove - removes this handler after being triggered
*/
-function onMessage (messageType, handler, remove) {
- window.addEventListener('message', function ({ data }) {
+function onMessage (messageType, callback, remove) {
+ const handler = function ({ data }) {
if (!data || data.type !== messageType) { return }
remove && window.removeEventListener('message', handler)
- handler.apply(window, arguments)
- })
+ callback.apply(window, arguments)
+ }
+ window.addEventListener('message', handler)
}
//