Skip to content

Commit d99ae46

Browse files
authored
fix: recreate channels on load (#204)
1 parent d0b906a commit d99ae46

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

nx/blocks/shell/shell.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { IMS_ORIGIN, loadIms } from '../../utils/ims.js';
77
import { DA_ORIGIN } from '../../public/utils/constants.js';
88

99
const IMS_DETAILS = await loadIms();
10-
const CHANNEL = new MessageChannel();
1110

1211
await import('../../public/sl/components.js');
1312

@@ -69,7 +68,10 @@ function getUrl() {
6968
* @param {HTMLIFrameElement} event.target - The loaded iframe element
7069
*/
7170
function handleLoad({ target }) {
72-
CHANNEL.port1.onmessage = (e) => {
71+
const channel = new MessageChannel();
72+
const { port1, port2 } = channel;
73+
74+
port1.onmessage = (e) => {
7375
if (e.data.action === 'setTitle') {
7476
document.title = e.data.details;
7577
}
@@ -82,7 +84,7 @@ function handleLoad({ target }) {
8284
};
8385

8486
setTimeout(() => {
85-
target.contentWindow.postMessage(message, '*', [CHANNEL.port2]);
87+
target.contentWindow.postMessage(message, '*', [port2]);
8688
}, 750);
8789
}
8890

0 commit comments

Comments
 (0)