Skip to content

Commit fc5727c

Browse files
committed
fix instrumentation of auto-subscription self-assignments (#2681)
1 parent 5263354 commit fc5727c

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

src/compile/render-dom/index.ts

Lines changed: 1 addition & 1 deletion
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;
Lines changed: 8 additions & 0 deletions
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+
};
Lines changed: 11 additions & 0 deletions
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)