Skip to content

Commit 0f23191

Browse files
committed
fix
1 parent 0a66964 commit 0f23191

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

packages/repl/src/lib/Output/Viewer.svelte

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -164,26 +164,32 @@
164164
{
165165
const { mount, unmount, App } = __repl_exports;
166166
167+
const render_app = () => {
168+
const component = mount(App, { target: document.body });
167169
168-
window.initialize = () => {
169-
var script = document.createElement('script');
170-
script.src = 'https://cdn.jsdelivr.net/npm/[email protected]/public/target.js';
171-
script.setAttribute('embedded', 'true');
172-
script.setAttribute('cdn', 'https://cdn.jsdelivr.net/npm/chii/public');
173-
document.head.appendChild(script);
170+
window.__unmount_previous = () => {
171+
unmount(component);
172+
}
173+
};
174174
175-
script.onload = () => {
176-
const component = mount(App, { target: document.body });
175+
if (!window.initialize) {
176+
window.initialize = () => {
177+
var script = document.createElement('script');
178+
script.src = 'https://cdn.jsdelivr.net/npm/[email protected]/public/target.js';
179+
script.setAttribute('embedded', 'true');
180+
script.setAttribute('cdn', 'https://cdn.jsdelivr.net/npm/chii/public');
181+
document.head.appendChild(script);
177182
178-
window.__unmount_previous = () => {
179-
unmount(component);
180-
}
183+
script.onload = render_app;
181184
};
182-
};
183185
184-
setTimeout(() => {
185-
window.dispatchEvent(new Event('preview_ready'));
186-
}, 0);
186+
setTimeout(() => {
187+
window.dispatchEvent(new Event('preview_ready'));
188+
}, 0);
189+
} else {
190+
render_app();
191+
}
192+
187193
}
188194
//# sourceURL=playground:output
189195
`);

0 commit comments

Comments
 (0)