Skip to content

Commit

Permalink
Catch non function listeners
Browse files Browse the repository at this point in the history
  • Loading branch information
fastner committed Feb 13, 2018
1 parent 8546af8 commit ee1e00a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit ee1e00a

Please sign in to comment.