Skip to content

Commit

Permalink
more idiomatic while loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Jul 12, 2024
1 parent 1afcbc6 commit 9b9a268
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/svelte/src/compiler/phases/2-analyze/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -797,9 +797,9 @@ const legacy_scope_tweaker = {
}
} else if (binding?.kind === 'each' && binding.mutated) {
// Ensure that the array is marked as reactive even when only its entries are mutated
let idx = -1;
let ancestor = path.at(idx);
while (ancestor) {
let i = path.length;
while (i--) {
const ancestor = path[i];
if (
ancestor.type === 'EachBlock' &&
state.analysis.template.scopes.get(ancestor)?.declarations.get(node.name) === binding
Expand All @@ -811,7 +811,6 @@ const legacy_scope_tweaker = {
}
break;
}
ancestor = path.at(--idx);
}
}
}
Expand Down

0 comments on commit 9b9a268

Please sign in to comment.