-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove automatic var(…)
injection
#13537
Merged
Merged
Conversation
This file contains 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
There are a few properties that use "dashed-ident" values, this means that you can use `--my-thing` as-is without the `var(…)` around it. This causes issues because we are now injecting a `var(…)` where it's not needed. One potential solution is to create a list of properties where dashed idents can be used. However, they can _also_ use CSS custom properties that point to another dashed ident. A workaround that some people used is adding a `_` in front of the variable: `mt-[_--my-thing]` this way we don't automatically inject the `var(…)` around it. This is a workaround and gross. While the idea of automatic var injection is neat, this causes more trouble than it's worth. Adding `var(…)` explicitly is better. A side effect of this is that we can simplify the `candidate` data structure because we don't need to track `dashedIdent` separately anymore.
RobinMalfait
force-pushed
the
remove-automatic-var-injection
branch
from
April 17, 2024 12:16
e09df91
to
607e101
Compare
thecrypticace
approved these changes
Apr 17, 2024
Nice, think this is probably the right move. Before we merge this though we should prove we can write a codemod to upgrade people, maybe can do that early next cycle. |
@adamwathan yep, I already added this to our list of breaking changes so we don't forget. I'm sure there are more things we can write codemods for. |
RobinMalfait
added a commit
that referenced
this pull request
May 8, 2024
This reverts commit cd4711c.
RobinMalfait
added a commit
that referenced
this pull request
May 8, 2024
This reverts commit 3a59340.
RobinMalfait
added a commit
that referenced
this pull request
Sep 23, 2024
This PR is a continuation of #13537. Currently we reverted the merged changes so that we can get a new alpha version out without this change. --- This PR removes automatic `var(…)` injection for arbitrary properties, values and modifiers. There are a few properties that use "dashed-ident" values, this means that you can use `--my-thing` as-is without the `var(…)` around it. E.g.: ```css .foo { /* Notice that these don't have `var(…)` */ view-timeline-name: --timeline-name; anchor-name: --sidebar; } ``` This causes issues because we are now injecting a `var(…)` where it's not needed. One potential solution is to create a list of properties where dashed idents can be used. However, they can _also_ use CSS custom properties that point to another dashed ident. E.g.: ```css .foo { --target: --sidebar; anchor-name: var(--target); } ``` A workaround that some people used is adding a `_` in front of the variable: `mt-[_--my-thing]` this way we don't automatically inject the `var(…)` around it. This is a workaround and gross. While the idea of automatic var injection is neat, this causes more trouble than it's worth. Adding `var(…)` explicitly is better. A side effect of this is that we can simplify the internals for the `candidate` data structure because we don't need to track `dashedIdent` separately anymore. <!-- 👋 Hey, thanks for your interest in contributing to Tailwind! **Please ask first before starting work on any significant new features.** It's never a fun experience to have your pull request declined after investing a lot of time and effort into a new feature. To avoid this from happening, we request that contributors create an issue to first discuss any significant new features. This includes things like adding new utilities, creating new at-rules, or adding new component examples to the documentation. https://github.com/tailwindcss/tailwindcss/blob/master/.github/CONTRIBUTING.md -->
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.
This PR removes automatic
var(…)
injection for arbitrary properties, values and modifiers.There are a few properties that use "dashed-ident" values, this means
that you can use
--my-thing
as-is without thevar(…)
around it.E.g.:
This causes issues because we are now injecting a
var(…)
where it's not needed.One potential solution is to create a list of properties where dashed idents can be used. However, they can also use CSS custom properties that point to another dashed ident.
E.g.:
A workaround that some people used is adding a
_
in front of the variable:mt-[_--my-thing]
this way we don't automatically inject thevar(…)
around it. This is a workaround and gross.While the idea of automatic var injection is neat, this causes more trouble than it's worth. Adding
var(…)
explicitly is better.A side effect of this is that we can simplify the internals for the
candidate
data structure because we don't need to trackdashedIdent
separately anymore.