Skip to content

Commit

Permalink
Replace for of with forEach to prevent Symbol polyfill in IE11
Browse files Browse the repository at this point in the history
  • Loading branch information
fastner committed Feb 14, 2018
1 parent d7dda9c commit 45c5150
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ function interframe(targetWindow, origin = "*", sourceWindow) {
listeners.get(namespace).add(callback)

if (outstandingMessages.has(namespace)) {
for (const message of outstandingMessages.get(namespace).values()) {
callback(message)
}

outstandingMessages.get(namespace).forEach((message) => callback(message))
outstandingMessages.delete(namespace)
}

Expand Down Expand Up @@ -108,16 +105,14 @@ function interframe(targetWindow, origin = "*", sourceWindow) {

isHandshaken = true

for (const hsCallback of handshakeCallback) {
hsCallback()
}
handshakeCallback.forEach((hsCallback) => hsCallback())
handshakeCallback.clear()

for (const sendItem of preHandshakeSendQueue.values()) {
preHandshakeSendQueue.forEach((sendItem) =>
send(sendItem.namespace, sendItem.data, sendItem.responseId)
.then((response) => sendItem.resolve(response)) // eslint-disable-line promise/prefer-await-to-then
.catch(() => sendItem.resolve())
}
)
preHandshakeSendQueue.clear()
}

Expand Down Expand Up @@ -151,14 +146,14 @@ function interframe(targetWindow, origin = "*", sourceWindow) {
const message = createMessage(messageData)

if (listeners.has(message.namespace)) {
for (const listener of listeners.get(message.namespace).values()) {
listeners.get(message.namespace).forEach((listener) => {
// 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)) {
outstandingMessages.set(message.namespace, new Set())
Expand Down

0 comments on commit 45c5150

Please sign in to comment.