-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Don’t split vars with numbers in them inside arbitrary values #8091
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { normalize } from '../src/util/dataTypes' | ||
|
||
let table = [ | ||
['foo', 'foo'], | ||
['foo-bar', 'foo-bar'], | ||
['16/9', '16 / 9'], | ||
|
||
// '_'s are converted to spaces except when escaped | ||
['foo_bar', 'foo bar'], | ||
['foo__bar', 'foo bar'], | ||
['foo\\_bar', 'foo_bar'], | ||
|
||
// Urls are preserved as-is | ||
[ | ||
'url("https://example.com/abc+def/some-path/2022-01-01-abc/some_underscoered_path")', | ||
'url("https://example.com/abc+def/some-path/2022-01-01-abc/some_underscoered_path")', | ||
], | ||
|
||
// var(…) is preserved as is | ||
['var(--foo)', 'var(--foo)'], | ||
['var(--headings-h1-size)', 'var(--headings-h1-size)'], | ||
|
||
// calc(…) get's spaces around operators | ||
['calc(1+2)', 'calc(1 + 2)'], | ||
['calc(100%+1rem)', 'calc(100% + 1rem)'], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would maybe add 1 more test with nested There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added and it works as expected 🎉 |
||
['calc(1+calc(100%-20px))', 'calc(1 + calc(100% - 20px))'], | ||
['calc(var(--headings-h1-size)*100)', 'calc(var(--headings-h1-size) * 100)'], | ||
[ | ||
'calc(var(--headings-h1-size)*calc(100%+50%))', | ||
'calc(var(--headings-h1-size) * calc(100% + 50%))', | ||
], | ||
['var(--heading-h1-font-size)', 'var(--heading-h1-font-size)'], | ||
['var(--my-var-with-more-than-3-words)', 'var(--my-var-with-more-than-3-words)'], | ||
['var(--width, calc(100%+1rem))', 'var(--width, calc(100% + 1rem))'], | ||
|
||
// Misc | ||
['color(0_0_0/1.0)', 'color(0 0 0 / 1.0)'], | ||
] | ||
|
||
it.each(table)('normalize data: %s', (input, output) => { | ||
expect(normalize(input)).toBe(output) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is strictly necessary, because
rgba(0 0 0/0.1)
seems to work as expected, but it generates cleaner css!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did this because we also apply spaces to aspect-[16/9]. I'd rather remove the spaces if that's fine though.