diff --git a/src/compiler/compile/render_dom/index.ts b/src/compiler/compile/render_dom/index.ts index 17e5eaf750b3..71e868164602 100644 --- a/src/compiler/compile/render_dom/index.ts +++ b/src/compiler/compile/render_dom/index.ts @@ -167,7 +167,7 @@ export default function dom( `; } - const capturable_vars = component.vars.filter(v => !v.internal && !v.name.startsWith('$$')); + const capturable_vars = component.vars.filter(v => !v.internal && !v.global && !v.name.startsWith('$$')); if (capturable_vars.length > 0) { capture_state = x`() => ({ ${capturable_vars.map(prop => p`${prop.name}`)} })`; diff --git a/test/js/samples/loop-protect/expected.js b/test/js/samples/loop-protect/expected.js index 127addf1d117..4eccaae7cb79 100644 --- a/test/js/samples/loop-protect/expected.js +++ b/test/js/samples/loop-protect/expected.js @@ -108,7 +108,7 @@ function instance($$self, $$props, $$invalidate) { }); } - $$self.$capture_state = () => ({ node, foo, console }); + $$self.$capture_state = () => ({ node, foo }); $$self.$inject_state = $$props => { if ("node" in $$props) $$invalidate(0, node = $$props.node); @@ -153,4 +153,4 @@ class Component extends SvelteComponentDev { } } -export default Component; \ No newline at end of file +export default Component;