Skip to content

Commit 0786d28

Browse files
authored
exclude global variables from $capture_state (#4475)
1 parent b8bf364 commit 0786d28

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/compiler/compile/render_dom/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export default function dom(
167167
`;
168168
}
169169

170-
const capturable_vars = component.vars.filter(v => !v.internal && !v.name.startsWith('$$'));
170+
const capturable_vars = component.vars.filter(v => !v.internal && !v.global && !v.name.startsWith('$$'));
171171

172172
if (capturable_vars.length > 0) {
173173
capture_state = x`() => ({ ${capturable_vars.map(prop => p`${prop.name}`)} })`;

test/js/samples/loop-protect/expected.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function instance($$self, $$props, $$invalidate) {
108108
});
109109
}
110110

111-
$$self.$capture_state = () => ({ node, foo, console });
111+
$$self.$capture_state = () => ({ node, foo });
112112

113113
$$self.$inject_state = $$props => {
114114
if ("node" in $$props) $$invalidate(0, node = $$props.node);
@@ -153,4 +153,4 @@ class Component extends SvelteComponentDev {
153153
}
154154
}
155155

156-
export default Component;
156+
export default Component;

0 commit comments

Comments
 (0)