Skip to content

Commit 9b9a268

Browse files
committed
more idiomatic while loop
1 parent 1afcbc6 commit 9b9a268

File tree

1 file changed

+3
-4
lines changed
  • packages/svelte/src/compiler/phases/2-analyze

1 file changed

+3
-4
lines changed

packages/svelte/src/compiler/phases/2-analyze/index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -797,9 +797,9 @@ const legacy_scope_tweaker = {
797797
}
798798
} else if (binding?.kind === 'each' && binding.mutated) {
799799
// Ensure that the array is marked as reactive even when only its entries are mutated
800-
let idx = -1;
801-
let ancestor = path.at(idx);
802-
while (ancestor) {
800+
let i = path.length;
801+
while (i--) {
802+
const ancestor = path[i];
803803
if (
804804
ancestor.type === 'EachBlock' &&
805805
state.analysis.template.scopes.get(ancestor)?.declarations.get(node.name) === binding
@@ -811,7 +811,6 @@ const legacy_scope_tweaker = {
811811
}
812812
break;
813813
}
814-
ancestor = path.at(--idx);
815814
}
816815
}
817816
}

0 commit comments

Comments
 (0)