fix: improve REPL console method wrapping (#11150)

* fix: improve REPL console method wrapping

* fix: improve REPL console method wrapping
pull/11133/head
Dominic Gannaway 9 months ago committed by GitHub
parent 19144b000f
commit 4b52884b8a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -140,14 +140,21 @@
// can get deeply read and tracked by accident when using the console. We can avoid this by // can get deeply read and tracked by accident when using the console. We can avoid this by
// ensuring we untrack the main console methods. // ensuring we untrack the main console methods.
const original = {};
for (const method of console_methods) { for (const method of console_methods) {
const original = console[method]; original[method] = console[method];
console[method] = function (...v) { console[method] = function (...v) {
return untrack(() => original.apply(this, v)); return untrack(() => original[method].apply(this, v));
} }
} }
const component = mount(App, { target: document.body }); const component = mount(App, { target: document.body });
window.__unmount_previous = () => unmount(component); window.__unmount_previous = () => {
for (const method of console_methods) {
console[method] = original[method];
}
unmount(component);
}
} }
//# sourceURL=playground:output //# sourceURL=playground:output
`); `);

Loading…
Cancel
Save