Skip to content

Commit

Permalink
fix: setting port variable when there are multiple ports (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
levivilet authored Sep 28, 2024
1 parent fc94ac6 commit 67a6d84
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions files/previewInjectedCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,15 @@ const handleMessageFromTestPort = (event) => {
const handleWindowMessage = (event) => {
const { data } = event
const message = data
port = message.params[0]
const innerPort = message.params[0]
const portType = message.params[1]
if (portType === 'test') {
port.onmessage = handleMessageFromTestPort
port.postMessage('ready')
innerPort.onmessage = handleMessageFromTestPort
innerPort.postMessage('ready')
} else {
port.onmessage = handleMessage
port.postMessage('ready')
innerPort.onmessage = handleMessage
innerPort.postMessage('ready')
port = innerPort
}
}

Expand Down

0 comments on commit 67a6d84

Please sign in to comment.