source may be null

This commit is contained in:
tophf 2021-07-30 16:53:15 +03:00
parent 8f519f8494
commit 7d54d908a2

View File

@ -29,9 +29,9 @@
},
});
window.addEventListener('message', ({data, source}) => {
// Accepting events only from this page.
if (data && source === window) {
window.addEventListener('message', ({data, source, origin}) => {
// Some browser don't reveal `source` to extensions e.g. Firefox
if (data && (source ? source === window : origin === ORIGIN)) {
const fn = HANDLERS[data.type];
if (fn) fn(data);
}