Skip to content

Canonicalization: keep whitespace-only arbitrary property values - #20719

Merged
RobinMalfait merged 1 commit into
tailwindlabs:mainfrom
SudeepGowda55:canonicalize-empty-custom-property
Nov 17, 2026
Merged

RobinMalfait merged 1 commit into
tailwindlabs:mainfrom
SudeepGowda55:canonicalize-empty-custom-property

Conversation

@SudeepGowda55

Copy link
Copy Markdown
Contributor

Summary

[--foo:_] sets a custom property to a single space, which is a common way to define an "empty" variable. Canonicalization rewrites it to [--foo:], which is not a valid candidate and generates no CSS at all, so applying the suggestion silently removes the style.

printArbitraryValue drops leading and trailing whitespace separators. When the value is nothing but whitespace, the only node is both the first and the last sibling, so it gets dropped and the value becomes empty. This only drops leading/trailing whitespace when there is something else next to it.

Test plan

  • Added [--foo:_] → [--foo:_] to the whitespace canonicalization tests in canonicalize-candidates.test.ts. On main it fails ([--foo:]), with the fix it passes.
  • pnpm vitest run in packages/tailwindcss: all tests pass.
  • prettier --check and pnpm changelog check pass.

@SudeepGowda55
SudeepGowda55 requested a review from a team as a code owner November 14, 2026 16:09
@greptile-apps

greptile-apps Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge.

Reviews (4) · Last reviewed commit: "Canonicalization: keep whitespace-only a..." · Reviewed by Greptile

@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 428dfe3b-1812-4882-8a78-9067367c82da
Commits

Reviewing files that changed from the base of the PR and between 6af35da and 2b5be18.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

Canonicalization now removes leading or trailing whitespace separators only when the parsed value has more than one sibling. A test verifies that [--foo:_] remains unchanged. The changelog records the fix.

Merge Risk: Minimal · previous review c0872

This fixes canonicalization so a whitespace-only arbitrary property value like [--foo:_] is no longer turned into an invalid candidate. The change is small and has a test and a changelog entry. No merge-blocking risk is apparent.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: whitespace-only arbitrary property values are kept during canonicalization. The raw summary confirms the change to printArbitraryValueCache in candidate.ts, which keep…
Description check Passed The description states the bug: canonicalization rewrites [--foo:_] to [--foo:], which generates no CSS. It explains the cause in printArbitraryValue and describes the test added to canonicalize-candi…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: whitespace-only arbitrary property values are kept during canonicalization. The raw summary confirms the change to printArbitraryValueCache in candidate.ts, which keeps single-sibling whitespace. The title is specific and matches the changeset.

Full details: Description check

Explanation

The description states the bug: canonicalization rewrites [--foo:_] to [--foo:], which generates no CSS. It explains the cause in printArbitraryValue and describes the test added to canonicalize-candidates.test.ts. This matches the changeset.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b46d530d-f8f3-41a2-8c5b-3990ceb0118f
Commits

Reviewing files that changed from the base of the PR and between b08bf83 and c0872de.

Files selected for processing: 3

  • .changelog/canonicalize-whitespace-only-value.md
  • packages/tailwindcss/src/candidate.ts
  • packages/tailwindcss/src/canonicalize-candidates.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@RobinMalfait
RobinMalfait self-requested a review November 16, 2026 21:31
@RobinMalfait RobinMalfait self-assigned this Nov 16, 2026
@RobinMalfait
RobinMalfait force-pushed the canonicalize-empty-custom-property branch from c0872de to 6af35da Compare November 16, 2026 21:32
@RobinMalfait

Copy link
Copy Markdown
Contributor

I rebased this PR on the latest main and force pushed it.

Sent by an AI assistant on behalf of @RobinMalfait.

@RobinMalfait
RobinMalfait force-pushed the canonicalize-empty-custom-property branch from 6af35da to 2b5be18 Compare November 17, 2026 10:48
@RobinMalfait
RobinMalfait enabled auto-merge (squash) November 17, 2026 10:48

@RobinMalfait RobinMalfait left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the PR! Nice, small fix for the whitespace-only case.

Sent by an AI assistant on behalf of @RobinMalfait.

@RobinMalfait
RobinMalfait merged commit 50fa2e8 into tailwindlabs:main Nov 17, 2026
13 checks passed
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.

2 participants