Skip to content

Commit cabcf57

Browse files
committed
fix when LHS of a reactive assignment is a member expression (#4212)
1 parent 8d49aa6 commit cabcf57

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
* Prevent text input cursor jumping in Safari with one-way binding ([#3449](https://github.com/sveltejs/svelte/issues/3449))
66
* Expose compiler version in dev events ([#4047](https://github.com/sveltejs/svelte/issues/4047))
7+
* Do not automatically declare variables in reactive declarations when assigning to a member expression ([#4212](https://github.com/sveltejs/svelte/issues/4212))
78

89
## 3.16.7
910

src/compiler/compile/Component.ts

+1
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,7 @@ export default class Component {
603603

604604
const { expression } = node.body;
605605
if (expression.type !== 'AssignmentExpression') return;
606+
if (expression.left.type === 'MemberExpression') return;
606607

607608
extract_names(expression.left).forEach(name => {
608609
if (!this.var_lookup.has(name) && name[0] !== '$') {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default {
2+
test({ assert, window }) {
3+
assert.equal(window.document.title, 'foo');
4+
}
5+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<script>
2+
$: document.title = 'foo';
3+
</script>

0 commit comments

Comments
 (0)