fix(web): track in-place class mutations - #3191
Conversation
🦋 Changeset detectedLatest commit: e90f776 The changes in this PR will be included in the next version bump. This PR includes changesets to release 11 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Merging this PR will not alter performance
Comparing Footnotes
|
|
I independently validated the implementation and tests: the per-element applied-class snapshot is the right fix, including hydration seeding and preservation of externally added classes. This is good to land.
|
f990181 to
097025f
Compare
|
@ryansolid, thanks for your review. I went to bed yesterday and wasn't able to reply right away. |
097025f to
23ca619
Compare
Document and ratchet the two app scenarios that retain the in-place class mutation fix. Co-authored-by: Cursor <cursoragent@cursor.com>
23ca619 to
e90f776
Compare
Summary
fix #3188
Object-valued
classbindings did not update correctly when the same object was mutated in place and passed through a signal using{ equals: false }.The previous value retained the same object reference, so the class diff compared the mutated object against itself and could no longer determine which classes had previously been applied.
This change stores an independent snapshot of the classes applied by
className(). It allows in-place mutations to be diffed correctly while preserving classes added by external code.The snapshot is also initialized during hydration so subsequent in-place updates behave consistently on claimed DOM nodes.
How did you test this change?
Added regression tests covering:
classbindingRan:
pnpm --filter @solidjs/web build pnpm --filter @solidjs/web types cd packages/web ../../node_modules/.bin/vitest run ../../node_modules/.bin/vitest run --config vite.config.server.mjs ../../node_modules/.bin/vitest run --config vite.config.hydrate.mjs ../../node_modules/.bin/tsc --project tsconfig.test.json ../../node_modules/.bin/prettier --check \ src/client.ts \ test/class.spec.tsx \ test/hydration/class.spec.tsx \ ../../.changeset/track-applied-classes.mdResults: