Skip to content

Commit 4b52884

Browse files
authored
fix: improve REPL console method wrapping (#11150)
* fix: improve REPL console method wrapping * fix: improve REPL console method wrapping
1 parent 19144b0 commit 4b52884

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,21 @@
140140
// can get deeply read and tracked by accident when using the console. We can avoid this by
141141
// ensuring we untrack the main console methods.
142142
143+
const original = {};
144+
143145
for (const method of console_methods) {
144-
const original = console[method];
146+
original[method] = console[method];
145147
console[method] = function (...v) {
146-
return untrack(() => original.apply(this, v));
148+
return untrack(() => original[method].apply(this, v));
147149
}
148150
}
149151
const component = mount(App, { target: document.body });
150-
window.__unmount_previous = () => unmount(component);
152+
window.__unmount_previous = () => {
153+
for (const method of console_methods) {
154+
console[method] = original[method];
155+
}
156+
unmount(component);
157+
}
151158
}
152159
//# sourceURL=playground:output
153160
`);

0 commit comments

Comments
 (0)