From ee1e00a06b9bfaba9508030623207b3b6d8cbfa0 Mon Sep 17 00:00:00 2001 From: Sebastian Fastner Date: Tue, 13 Feb 2018 15:23:50 +0100 Subject: [PATCH] Catch non function listeners --- src/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 586e850..f69ce0b 100644 --- a/src/index.js +++ b/src/index.js @@ -152,7 +152,12 @@ function interframe(targetWindow, origin = "*", sourceWindow) { if (listeners.has(message.namespace)) { for (const listener of listeners.get(message.namespace).values()) { - listener(createMessage(message)) + // eslint-disable-next-line max-depth + if (typeof listener === "function") { + listener(createMessage(message)) + } else if (listener) { + console.error("Listener is no function: ", listener) // eslint-disable-line + } } } else { if (!outstandingMessages.has(message.namespace)) {