mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
parent
b58a9bd202
commit
89c4353408
@ -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)
|
||||
}
|
||||
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user