Skip to content

Preserve class-object property identities during sorting - #479

Open
MikeeI wants to merge 1 commit into
tailwindlabs:mainfrom
MikeeI:fix/issue-002-preserve-object-key-identity
Open

MikeeI wants to merge 1 commit into
tailwindlabs:mainfrom
MikeeI:fix/issue-002-preserve-object-key-identity

Conversation

@MikeeI

@MikeeI MikeeI commented Oct 21, 2026

Copy link
Copy Markdown

Summary

Sorting can merge distinct conditional keys or split duplicate identities, changing which property wins.
For example, clsx({ 'underline flex': true, 'flex underline': false }) loses its active classes.
Plan actual serialized key identities before mutation and preserve unsafe identity groups.
Keep collision-free supported static keys sortable, including duplicate cohorts that move together safely.
Conservatively preserve keys under spread/computed composition without evaluating expressions.
Carry full key context through global sorter reentry so identity plans and writes agree on whitespace.

Previous class-key support: #155

Verification

  • Added parser-family regressions for collisions, raw escapes, unknown composition, and global reentry.
  • Real clsx evaluation preserved static-collision, nested-spread, and escaped-duplicate results.
  • pnpm run format --check, pnpm run lint, and pnpm run build passed.
  • pnpm run test --run: 120 passed, four existing skips.

Tested with Node.js 26.12.0, pnpm 10.28.2, and lockfile-pinned Prettier 3.9.6.
The src/config.ts change is only repository-formatter normalization of an existing signature.

Disclosure

Investigated thoroughly with openai-codex/gpt-6.1-sol (medium reasoning effort), using Oh My Pi as the agent framework.
I thoroughly reviewed this contribution with openai-codex/gpt-6.1-sol (medium reasoning effort).

This report is not generic or unreviewed AI-generated output.
Its claims were checked against the cited evidence, and it includes the relevant detail intended to help maintainers resolve the issue.

If reports like this are not useful to the project, please let me know and I will refrain from submitting similar ones.
My intent is to help without wasting maintainer time or energy or discouraging their work.

Thank you for your work.

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.

1 participant