Skip to content

Commit 87963cf

Browse files
committed
we can simplify this further - no need to check the value was transformed, since the outcome of not returning immediately is the same but with extra steps
1 parent 6b34316 commit 87963cf

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

packages/svelte/src/compiler/phases/3-transform/client/visitors/AssignmentExpression.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,19 @@ function build_assignment(operator, left, right, context) {
3737
const private_state = context.state.private_state.get(left.property.name);
3838

3939
if (private_state !== undefined) {
40-
let transformed = false;
4140
let value = /** @type {Expression} */ (
4241
context.visit(build_assignment_value(operator, left, right))
4342
);
4443

45-
if (should_proxy(value, context.state.scope)) {
46-
transformed = true;
47-
value =
48-
private_state.kind === 'raw_state'
49-
? value
50-
: build_proxy_reassignment(value, b.member(b.this, private_state.id));
44+
if (private_state.kind !== 'raw_state' && should_proxy(value, context.state.scope)) {
45+
value = build_proxy_reassignment(value, b.member(b.this, private_state.id));
5146
}
5247

53-
if (!context.state.in_constructor) {
54-
return b.call('$.set', left, value);
55-
} else if (transformed) {
48+
if (context.state.in_constructor) {
5649
return b.assignment(operator, /** @type {Pattern} */ (context.visit(left)), value);
5750
}
51+
52+
return b.call('$.set', left, value);
5853
}
5954
}
6055

0 commit comments

Comments
 (0)