Skip to content

Commit

Permalink
chore: create binding.updated getter (#15362)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris authored Feb 24, 2025
1 parent 53d1b17 commit bfeb9ad
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/svelte/src/compiler/phases/2-analyze/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ export function analyze_component(root, source, options) {
binding.declaration_kind !== 'import'
) {
binding.kind = 'state';
binding.mutated = binding.updated = true;
binding.mutated = true;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function ExportSpecifier(node, context) {
});

const binding = context.state.scope.get(local_name);
if (binding) binding.reassigned = binding.updated = true;
if (binding) binding.reassigned = true;
}
} else {
validate_export(node, context.state.scope, local_name);
Expand Down
7 changes: 4 additions & 3 deletions packages/svelte/src/compiler/phases/scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ export class Binding {
is_called = false;
mutated = false;
reassigned = false;
updated = false;

/**
*
Expand All @@ -77,6 +76,10 @@ export class Binding {
this.kind = kind;
this.declaration_kind = declaration_kind;
}

get updated() {
return this.mutated || this.reassigned;
}
}

export class Scope {
Expand Down Expand Up @@ -738,8 +741,6 @@ export function create_scopes(ast, root, allow_reactive_declarations, parent) {
const binding = left && scope.get(left.name);

if (binding !== null && left !== binding.node) {
binding.updated = true;

if (left === expression) {
binding.reassigned = true;
} else {
Expand Down

0 comments on commit bfeb9ad

Please sign in to comment.