Repository navigation
Conversation
…en inlining A value left for inlining could pick up `initial` or `inherit` from a class like `duration-initial`. Also drop a selector check that never decided anything. Refs resend#3931
🦋 Changeset detectedLatest commit: 12973b7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 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 |
Contributor
|
@Maliik-B is attempting to deploy a commit to the resend Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
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.
Related issue or discussion
Refs #3931. This fixes the text shadow and gradient cases; drop-shadow follows in a separate PR.
What this changes
resolveAllCssVariablesruns over the whole stylesheet before styles are inlined per element. When a rule used a variable it doesn't define, its fallback was written in at that stage, before the element's other classes were seen. Sotext-shadow-red-500was ignored, andbg-radial-[at_25%_25%],bg-linear-[25deg]andbg-conic-[from_45deg]lost their color stops.#3803 already leaves a custom property's fallback for inline time, because another class may still define it. This does the same for regular properties when another class rule defines the variable, and
makeInlineStylesForresolves it per element (#3768). Only rules whose selector is a single class make a fallback wait, and a rule's own definitions still resolve early. Whether a fallback waits depends on the cached stylesheet, but every built-in utility on its own renders the same either way.Other classes that read a variable another class sets follow too:
leading-[24px] text-smkeeps24px, andduration-300 transitiongives300ms.A value left for inline time could pick up
initialfrom a class likeduration-initial, so when a variable is set to a CSS-wide keyword and there is a fallback or registered initial value,makeInlineStylesFornow uses that instead, as a browser does when no ancestor sets the variable. That also fixes the-initialand-inheritvariants ofshadow,inset-shadow,ringandring-offset, plusvia-noneandfrom-inherit, which inlined the keyword.drop-shadow-lgbakes its own--tw-drop-shadowintofilterthrough a different path, which needs more changes, so it comes separately.Not addressed
text-shadow-red-500/50) the color now applies but keeps an unfoldedcolor-mix, asshadow-md shadow-blue-500/50does (fix(react-email): resolve theme variables used inside Tailwind utility variables #3803's note). It used to render black.text-shadow-[#ff000080]now get the five-argumentrgb()thatshadow-[#ff000080]already gets, which browsers drop, so the shadow disappears.aria-checked:,data-[state=open]:,[&_p]:) reach shadows and gradient stops when a plain class for the same variable is in the stylesheet, from this render or an earlier one, as they already do for box shadows. In user CSS,.dark .cardapplies the same way once a plain class defines its variable.margin-block: var(--m, 1rem 2rem)andpadding-inlinesplit it wrongly, andcalc(infinity * 1px)stays instead of becoming9999px. With arbitrary values it depends on the other classes in the stylesheet, from this render or an earlier one. A variable read asvar(--m,)and set toinitialnow stays asvar(--m,).@propertyinitial value now replaces a fallback once any class in the stylesheet defines the variable, as in browsers.Tests
makeInlineStylesFor: a variable set toinitialfalls back, and keepsinitialwith nothing to fall back to.<Tailwind>: colored and default siblings,leading-[24px] text-smand the gradient; a render-order guard.makeInlineStylesForand render tests fail oncanary; the guards pass there. No existing snapshot changed.canaryon its own sheet and beside the classes that share its variables.pnpm lintandpnpm typecheckpass;pnpm testpasses except two CLI specs that fail oncanaryon Windows too.AI disclosure: written with Claude's help. I reviewed the change and the tests before opening this.
Checklist
Summary by cubic
Fixes
<Tailwind>so utilities that read a CSS variable another class on the same element defines now use that value instead of the fallback. This correctstext-shadow-*colors, gradients with arbitrary positions (e.g.,bg-radial-[at_25%_25%]) losing their color stops, andleading-*being overridden bytext-*. When a variable is set to a CSS-wide keyword likeinitialorinherit, the fallback is now used instead of inlining the keyword, matching browser behavior.Key changes
makeInlineStylesFortreats a variable declared with a CSS-wide keyword as unset when a fallback exists.Written for commit 12973b7. Summary will update on new commits.