Skip to content

Commit 50ae572

Browse files
authored
Merge pull request #3538 from sveltejs/gh-3537
invalidate store values in <script> block
2 parents 670fadf + c12e7d6 commit 50ae572

File tree

5 files changed

+33
-1
lines changed

5 files changed

+33
-1
lines changed

src/compiler/compile/utils/invalidate.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ export function invalidate(component: Component, scope: Scope, code: MagicString
1818
(
1919
variable.referenced ||
2020
variable.is_reactive_dependency ||
21-
variable.export_name
21+
variable.export_name ||
22+
variable.name[0] === '$'
2223
)
2324
);
2425
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<script>
2+
import { count } from './store.js';
3+
</script>
4+
5+
<p>count: {$count}</p>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { count } from './store.js';
2+
3+
export default {
4+
html: `<p>count: 0</p>`,
5+
6+
async test({ assert, component, target }) {
7+
await component.increment();
8+
9+
assert.htmlEqual(target.innerHTML, `<p>count: 1</p>`);
10+
11+
count.set(0);
12+
}
13+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<script>
2+
import Nested from './Nested.svelte';
3+
import { count } from './store.js';
4+
5+
export function increment() {
6+
$count++;
7+
}
8+
</script>
9+
10+
<Nested />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { writable } from '../../../../store';
2+
3+
export const count = writable(0);

0 commit comments

Comments
 (0)