From 67a6d84fe674dcc3a2cc41c4269f1fa628141eb2 Mon Sep 17 00:00:00 2001 From: Le Vivilet <72156503+levivilet@users.noreply.github.com> Date: Sat, 28 Sep 2024 16:04:48 +0200 Subject: [PATCH] fix: setting port variable when there are multiple ports (#50) --- files/previewInjectedCode.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/files/previewInjectedCode.js b/files/previewInjectedCode.js index 8e4ae5c7..6677eddd 100644 --- a/files/previewInjectedCode.js +++ b/files/previewInjectedCode.js @@ -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 } }