Merge pull request #3538 from sveltejs/gh-3537

invalidate store values in <script> block
pull/3540/head
Rich Harris 5 years ago committed by GitHub
commit 50ae5724d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -18,7 +18,8 @@ export function invalidate(component: Component, scope: Scope, code: MagicString
(
variable.referenced ||
variable.is_reactive_dependency ||
variable.export_name
variable.export_name ||
variable.name[0] === '$'
)
);
});

@ -0,0 +1,5 @@
<script>
import { count } from './store.js';
</script>
<p>count: {$count}</p>

@ -0,0 +1,13 @@
import { count } from './store.js';
export default {
html: `<p>count: 0</p>`,
async test({ assert, component, target }) {
await component.increment();
assert.htmlEqual(target.innerHTML, `<p>count: 1</p>`);
count.set(0);
}
};

@ -0,0 +1,10 @@
<script>
import Nested from './Nested.svelte';
import { count } from './store.js';
export function increment() {
$count++;
}
</script>
<Nested />

@ -0,0 +1,3 @@
import { writable } from '../../../../store';
export const count = writable(0);
Loading…
Cancel
Save