chore: create `binding.updated` getter (#15362)

pull/15380/head
Rich Harris 7 months ago committed by GitHub
parent 53d1b17ce9
commit bfeb9ad448
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -565,7 +565,7 @@ export function analyze_component(root, source, options) {
binding.declaration_kind !== 'import' binding.declaration_kind !== 'import'
) { ) {
binding.kind = 'state'; binding.kind = 'state';
binding.mutated = binding.updated = true; binding.mutated = true;
} }
} }
} }

@ -22,7 +22,7 @@ export function ExportSpecifier(node, context) {
}); });
const binding = context.state.scope.get(local_name); const binding = context.state.scope.get(local_name);
if (binding) binding.reassigned = binding.updated = true; if (binding) binding.reassigned = true;
} }
} else { } else {
validate_export(node, context.state.scope, local_name); validate_export(node, context.state.scope, local_name);

@ -60,7 +60,6 @@ export class Binding {
is_called = false; is_called = false;
mutated = false; mutated = false;
reassigned = false; reassigned = false;
updated = false;
/** /**
* *
@ -77,6 +76,10 @@ export class Binding {
this.kind = kind; this.kind = kind;
this.declaration_kind = declaration_kind; this.declaration_kind = declaration_kind;
} }
get updated() {
return this.mutated || this.reassigned;
}
} }
export class Scope { export class Scope {
@ -738,8 +741,6 @@ export function create_scopes(ast, root, allow_reactive_declarations, parent) {
const binding = left && scope.get(left.name); const binding = left && scope.get(left.name);
if (binding !== null && left !== binding.node) { if (binding !== null && left !== binding.node) {
binding.updated = true;
if (left === expression) { if (left === expression) {
binding.reassigned = true; binding.reassigned = true;
} else { } else {

Loading…
Cancel
Save