Skip to content

Commit b623890

Browse files
authored
chore(repl): hide globals (#10125)
1 parent 1ff9c0f commit b623890

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

sites/svelte-5-preview/src/lib/Output/Viewer.svelte

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -111,26 +111,30 @@
111111
112112
${styles}
113113
114-
const styles = document.querySelectorAll('style[id^=svelte-]');
115-
116-
let i = styles.length;
117-
while (i--) styles[i].parentNode.removeChild(styles[i]);
118-
119-
if (window.unmount) {
120-
try {
121-
window.unmount();
122-
} catch (err) {
123-
console.error(err);
114+
{
115+
const styles = document.querySelectorAll('style[id^=svelte-]');
116+
117+
let i = styles.length;
118+
while (i--) styles[i].parentNode.removeChild(styles[i]);
119+
120+
if (window.__unmount_previous) {
121+
try {
122+
window.__unmount_previous();
123+
} catch (err) {
124+
console.error(err);
125+
}
124126
}
125-
}
126127
127-
document.body.innerHTML = '';
128-
window._svelteTransitionManager = null;
129-
130-
const { mount, App } = ${$bundle.client?.code};
131-
const [, destroy] = mount(App, { target: document.body });
128+
document.body.innerHTML = '';
129+
window._svelteTransitionManager = null;
130+
}
132131
133-
window.unmount = destroy;
132+
const __repl_exports = ${$bundle.client?.code};
133+
{
134+
const { mount, App } = __repl_exports;
135+
const [, destroy] = mount(App, { target: document.body });
136+
window.__unmount_previous = destroy;
137+
}
134138
//# sourceURL=playground:output
135139
`);
136140
error = null;

0 commit comments

Comments
 (0)