fix(solid): exclude keys shared across splitProps groups on the proxy path#2812
Open
spokodev wants to merge 1 commit into
Open
fix(solid): exclude keys shared across splitProps groups on the proxy path#2812spokodev wants to merge 1 commit into
spokodev wants to merge 1 commit into
Conversation
… path The proxy branch of splitProps built one Proxy per group whose get/has/keys each tested membership against that group's key list independently, with no cross-group exclusion. A key listed in two groups was therefore exposed by both proxied groups, while the plain-object path assigns each key to the first group that lists it (first-match break). Component props and stores are proxies at runtime, so the proxy path is the live one. Track keys claimed by earlier groups and let each group own only its not-yet-claimed keys, so get, has, and keys all honor the exclusion and match the plain-object semantics.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
splitPropsproxy path duplicates a key that is shared across two groups, disagreeing with its own plain-object path and with the documented contract that a property belongs to a single group.Repro
The key
bis consumed by the first group but still leaks into the second group through get, has, enumeration, and spread.Root cause
splitPropshas two implementations. The plain-object path walks each property once and assigns it to the first group that lists it (first-matchbreak), so keys are exclusive. The proxy path instead builds oneProxyper group whoseget/has/keyseach testk.includes(property)against that group's own key list, with no cross-group exclusion. A key present in two groups is therefore reported by both proxied groups. Component props and stores are proxies at runtime, so the proxy path is the one that actually runs for components.Fix
In the proxy branch, track keys claimed by earlier groups and let each group own only its not-yet-claimed keys.
get,has, andkeysall read from that owned set, bringing the proxy path to parity with the plain-object first-match semantics. Therestproxy is unchanged, since it already excludeskeys.flat().Authority
Solid docs state
splitPropspartitions props and each property belongs to one group, and the plain-object implementation in the same function already enforces this with a first-matchbreak.Tests
Added a case to
packages/solid/test/component.spec.tsasserting first-group-only ownership for both a plain object and acreateStoreproxy across get, has, keys, and spread. It fails on the current proxy path (expected 2 to be undefined) and passes with the fix.packages/solidsuite: 482 passing plus the new test. The only failure is the unrelated pre-existingweb/test/transition.spec.tsx"Transition memo stale read (#2046)" flake, which is nondeterministic and passes when run in isolation on the clean tree.