Skip to content

Commit d935762

Browse files
Fixed a false positive warning for content properties that included var() (#2700)
* Allow for CSS variables in content property * Update tests * Fixup tests * Create young-deers-cheat.md Co-authored-by: Mateusz Burzyński <[email protected]>
1 parent 1a25293 commit d935762

File tree

6 files changed

+12
-1
lines changed

6 files changed

+12
-1
lines changed

.changeset/young-deers-cheat.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@emotion/css": patch
3+
"@emotion/react": patch
4+
"@emotion/serialize": patch
5+
---
6+
7+
Fixed a false positive warning for `content` properties that included `var()`.

packages/css/test/__snapshots__/warnings.test.js.snap

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ exports[`does not warn when valid values are passed for the content property 1`]
1212
content: inherit;
1313
content: "some thing";
1414
content: 'another thing';
15+
content: var(--variable-name);
1516
content: url("http://www.example.com/test.png");
1617
content: linear-gradient(hotpink, #8be9fd);
1718
content: radial-gradient(hotpink, #8be9fd);

packages/css/test/warnings.test.js

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const validValues = [
1919
'inherit',
2020
'"some thing"',
2121
"'another thing'",
22+
'var(--variable-name)',
2223
'url("http://www.example.com/test.png")',
2324
'linear-gradient(hotpink, #8be9fd)',
2425
'radial-gradient(hotpink, #8be9fd)',

packages/react/__tests__/__snapshots__/warnings.js.snap

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ exports[`does not warn when valid values are passed for the content property 1`]
1212
content: inherit;
1313
content: "some thing";
1414
content: 'another thing';
15+
content: var(--variable-name);
1516
content: url("http://www.example.com/test.png");
1617
content: linear-gradient(hotpink, #8be9fd);
1718
content: radial-gradient(hotpink, #8be9fd);

packages/react/__tests__/warnings.js

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const validValues = [
1919
'inherit',
2020
'"some thing"',
2121
"'another thing'",
22+
'var(--variable-name)',
2223
'url("http://www.example.com/test.png")',
2324
'linear-gradient(hotpink, #8be9fd)',
2425
'radial-gradient(hotpink, #8be9fd)',

packages/serialize/src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ let processStyleValue = (
6161

6262
if (process.env.NODE_ENV !== 'production') {
6363
let contentValuePattern =
64-
/(attr|counters?|url|(((repeating-)?(linear|radial))|conic)-gradient)\(|(no-)?(open|close)-quote/
64+
/(var|attr|counters?|url|(((repeating-)?(linear|radial))|conic)-gradient)\(|(no-)?(open|close)-quote/
6565
let contentValues = ['normal', 'none', 'initial', 'inherit', 'unset']
6666

6767
let oldProcessStyleValue = processStyleValue

0 commit comments

Comments
 (0)