Skip to content

fix: replace for-in with indexed for loop in unhighlightSelectedBlocks#5903

Open
AdityaM-IITH wants to merge 1 commit intosugarlabs:masterfrom
AdityaM-IITH:fix-forin-loop-unhighlight-selected-blocks
Open

fix: replace for-in with indexed for loop in unhighlightSelectedBlocks#5903
AdityaM-IITH wants to merge 1 commit intosugarlabs:masterfrom
AdityaM-IITH:fix-forin-loop-unhighlight-selected-blocks

Conversation

@AdityaM-IITH
Copy link
Contributor

The unhighlightSelectedBlocks method in activity.js iterates over
this.blocks.blockList using a for...in loop.

for...in on arrays yields string keys ("0", "1", "2") instead of
numeric indices, which can cause silent failures when the index is
passed to functions expecting a number.

Changes:

  • Replace for...in with a standard indexed for loop

Consistent with the fix in #5888 which addressed the same pattern in
_saveHelpBlocks.

@github-actions
Copy link
Contributor

❌ Some Jest tests failed. Please check the logs and fix the issues before merging.

Failed Tests:

palette.test.js
logo.test.js
logoconstants.test.js

@AdityaM-IITH AdityaM-IITH force-pushed the fix-forin-loop-unhighlight-selected-blocks branch from 0913877 to 9176357 Compare February 25, 2026 16:28
@github-actions
Copy link
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@AdityaM-IITH
Copy link
Contributor Author

Rebased on latest master. All 117 test suites passing locally.

Copy link
Contributor

@7se7en72025 7se7en72025 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. @walterbender
Verified that the fix properly replaces the for...in anti-pattern with a standard indexed loop, which preserves numeric indices and aligns with #5888.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants