[CSS] bug when handling var(foo)
See original GitHub issuePrettier 1.15.1 Playground link
--parser css
Input:
.a/root {
transition: height var(transition-time)s;
}
Output:
.a/root {
transition: height var(transition-time) s;
}
Note the extra space after var(transition-time)
.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
CSS Custom Properties (var(--foo)) in theme secondary colour ...
Describe the bug Using CSS variables in theme breaks storybook. ... (var(--foo)) in theme secondary colour causes fatal error #6135.
Read more >CSS variables (custom properties) bug & a potential crash
Any news about this? I find that having a case where 22-characters if CSS cause a crash to be rather dangerous, as it...
Read more >Handling common HTML and CSS problems - MDN Web Docs
Note: One common problem with CSS and HTML arises when different CSS rules begin to conflict with one another. This can be especially ......
Read more >Can I access the value of invalid/custom CSS properties from ...
The CSSStyleDeclaration simply skips the invalid property. ... dash: --my-foo: 42; (they can be reused elsewhere like this font-size: var(--my-foo); ) ...
Read more >A user's guide to CSS variables – Increment: Frontend
They're loosely parsed at declaration time, but error handling isn't done until they're used in a noncustom property. Their values are referenced via...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It is hard to fix it, logic around spaces based on prev, current and next types (i.e. function/number with unit/variable and etc), it is allow add spaces for math operators in Less and Sass and in
calc
inCSS
, better avoid invalid CSS, it can lead to such consequences in many places, we can try to close this case, but then we can break the normal syntaxYeah, I guess we could try to keep it as written. Just wanted to make sure this is something worth doing something about on Prettier’s side first (it could have been a mistake).
(CSS is difficult since we support an arbitrary superset of the standard, which forces us to apply “garbage in, garbage out” instead of throwing parse errors sometimes, and it’s not easy to to know what’s garbage and what’s not.)