Skip to content

fix: Vue3 reactivity for Set/Map collections#66

Merged
treardon17 merged 2 commits into
mainfrom
fix/vue3-collection-reactivity
Dec 19, 2025
Merged

fix: Vue3 reactivity for Set/Map collections#66
treardon17 merged 2 commits into
mainfrom
fix/vue3-collection-reactivity

Conversation

@treardon17
Copy link
Copy Markdown
Collaborator

When Vue directly accesses a Set/Map (e.g., [...store.numbers]), Vue tracks Symbol.iterator. When the collection is modified via add() or set(), onSet was only notifying on the method name and undefined. Vue wasn't listening on those keys, so it didn't re-render.

The fix tracks which iteration keys Vue has accessed per target, and only notifies those specific keys when keysChanged is true. This is more efficient than notifying all possible iteration keys.

Also adds comprehensive test coverage for nested Set/Map reactivity:

  • observer_nested_collections.spec.ts (35 tests)
  • decorateNestedCollections.spec.ts (34 tests)
  • testVueCollections.ts (32 Vue3-specific tests)

🤖 Generated with Claude Code

📚 Bookkeeping:

Testing (if applicable):

  • Ran/wrote unit tests for this

Checklist

  • Assigned PR to myself
  • Added at least 1 person on the team as reviewer
  • Release Notes: PRs types that have the 🗒️ next to them also require release notes to be added to the CHANGELOG.md

When Vue directly accesses a Set/Map (e.g., [...store.numbers]), Vue
tracks Symbol.iterator. When the collection is modified via add() or
set(), onSet was only notifying on the method name and undefined.
Vue wasn't listening on those keys, so it didn't re-render.

The fix tracks which iteration keys Vue has accessed per target, and
only notifies those specific keys when keysChanged is true. This is
more efficient than notifying all possible iteration keys.

Also adds comprehensive test coverage for nested Set/Map reactivity:
- observer_nested_collections.spec.ts (35 tests)
- decorateNestedCollections.spec.ts (34 tests)
- testVueCollections.ts (32 Vue3-specific tests)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@treardon17 treardon17 requested a review from bitencode December 19, 2025 20:58
@treardon17 treardon17 self-assigned this Dec 19, 2025
@github-actions github-actions Bot added the fix label Dec 19, 2025
@treardon17 treardon17 merged commit 659f7be into main Dec 19, 2025
5 checks passed
@treardon17 treardon17 deleted the fix/vue3-collection-reactivity branch December 19, 2025 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant