Skip to content

Commit 117afe9

Browse files
authored
Merge pull request #2683 from sveltejs/gh-2681
fix instrumentation of auto-subscription self-assignments
2 parents 4bc93a3 + fc5727c commit 117afe9

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

src/compile/render-dom/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ export default function dom(
182182

183183
if (node.operator === '=' && nodes_match(node.left, node.right)) {
184184
const dirty = names.filter(name => {
185-
return scope.find_owner(name) === component.instance_scope;
185+
return name[0] === '$' || scope.find_owner(name) === component.instance_scope;
186186
});
187187

188188
if (dirty.length) component.has_reactive_assignments = true;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default {
2+
html: `[]`,
3+
4+
async test({ assert, component, target }) {
5+
await component.go();
6+
assert.htmlEqual(target.innerHTML, `[42]`);
7+
}
8+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<script>
2+
import { writable } from 'svelte/store';
3+
const foo = writable([]);
4+
$: bar = $foo;
5+
export function go() {
6+
$foo.push(42);
7+
$foo = $foo;
8+
}
9+
</script>
10+
11+
{JSON.stringify(bar)}

0 commit comments

Comments
 (0)