Skip to content

fix: revert Iterator helpers to array spread for browser compat#5259

Merged
marcoscaceres merged 2 commits into
speced:mainfrom
marcoscaceres:fix/5255-iterator-helpers
May 6, 2026
Merged

fix: revert Iterator helpers to array spread for browser compat#5259
marcoscaceres merged 2 commits into
speced:mainfrom
marcoscaceres:fix/5255-iterator-helpers

Conversation

@marcoscaceres
Copy link
Copy Markdown
Contributor

Closes #5255

.keys().find() on Set/Map iterators requires the ES2025 Iterator Helpers proposal (Chrome 117+, Firefox 131+, Safari 18+). In browsers without support, these throw TypeError, breaking variable highlighting (highlight-vars.runtime.js) and case-insensitive reference lookups (utils.js).

Reverts to [...keys()].find() which works in all browsers ReSpec targets. Introduced in the TypeScript 6 upgrade (#5169).

`.keys().find()` on Set/Map iterators requires the ES2025 Iterator
Helpers proposal (Chrome 117+, Firefox 131+, Safari 18+). In browsers
without support, these throw TypeError, breaking variable highlighting
and case-insensitive reference lookups.

Revert to `[...keys()].find()` which works in all browsers ReSpec
targets.

Closes speced#5255
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR restores browser compatibility by avoiding ES2025 Iterator Helpers usage (.keys().find()) on Set/Map iterators, which can throw in older browsers and break variable highlighting and case-insensitive key lookups.

Changes:

  • Replace iterator helper usage with array spread + find() in InsensitiveStringSet.getCanonicalKey().
  • Replace Map.prototype.keys().find(...) with [...keys()].find(...) in runtime variable highlighting.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/core/utils.js Switches iterator .find() to [...this.keys()].find() for case-insensitive canonical key lookup.
src/core/highlight-vars.runtime.js Switches iterator .find() to [...HL_COLORS.keys()].find() to keep highlight color selection working in older browsers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@marcoscaceres
Copy link
Copy Markdown
Contributor Author

@copilot Can you confirm all your feedback has been addressed? Can you fix anything that was not addressed?

@marcoscaceres marcoscaceres marked this pull request as ready for review May 4, 2026 13:05
@marcoscaceres marcoscaceres requested a review from sidvishnoi May 5, 2026 04:13
@marcoscaceres marcoscaceres enabled auto-merge (squash) May 6, 2026 03:51
@marcoscaceres marcoscaceres merged commit d32bbca into speced:main May 6, 2026
8 checks passed
@marcoscaceres marcoscaceres deleted the fix/5255-iterator-helpers branch May 10, 2026 17:07
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.

bug: Iterator helpers (.keys().find()) break in browsers without ES2025 support

3 participants