question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[CSS] bug when handling var(foo)

See original GitHub issue

Prettier 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:open
  • Created 5 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
alexander-akaitcommented, Nov 9, 2018

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 in CSS, 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 syntax

0reactions
lydellcommented, Nov 8, 2018

Yeah, 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.)

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found