Skip to content
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

Allow var() in content property #2700

Merged
merged 4 commits into from Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/young-deers-cheat.md
@@ -0,0 +1,7 @@
---
"@emotion/css": patch
"@emotion/react": patch
"@emotion/serialize": patch
---

Fixed a false positive warning for `content` properties that included `var()`.
1 change: 1 addition & 0 deletions packages/css/test/__snapshots__/warnings.test.js.snap
Expand Up @@ -12,6 +12,7 @@ exports[`does not warn when valid values are passed for the content property 1`]
content: inherit;
content: "some thing";
content: 'another thing';
content: var(--variable-name);
content: url("http://www.example.com/test.png");
content: linear-gradient(hotpink, #8be9fd);
content: radial-gradient(hotpink, #8be9fd);
Expand Down
1 change: 1 addition & 0 deletions packages/css/test/warnings.test.js
Expand Up @@ -19,6 +19,7 @@ const validValues = [
'inherit',
'"some thing"',
"'another thing'",
'var(--variable-name)',
'url("http://www.example.com/test.png")',
'linear-gradient(hotpink, #8be9fd)',
'radial-gradient(hotpink, #8be9fd)',
Expand Down
1 change: 1 addition & 0 deletions packages/react/__tests__/__snapshots__/warnings.js.snap
Expand Up @@ -12,6 +12,7 @@ exports[`does not warn when valid values are passed for the content property 1`]
content: inherit;
content: "some thing";
content: 'another thing';
content: var(--variable-name);
content: url("http://www.example.com/test.png");
content: linear-gradient(hotpink, #8be9fd);
content: radial-gradient(hotpink, #8be9fd);
Expand Down
1 change: 1 addition & 0 deletions packages/react/__tests__/warnings.js
Expand Up @@ -19,6 +19,7 @@ const validValues = [
'inherit',
'"some thing"',
"'another thing'",
'var(--variable-name)',
'url("http://www.example.com/test.png")',
'linear-gradient(hotpink, #8be9fd)',
'radial-gradient(hotpink, #8be9fd)',
Expand Down
2 changes: 1 addition & 1 deletion packages/serialize/src/index.js
Expand Up @@ -61,7 +61,7 @@ let processStyleValue = (

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

let oldProcessStyleValue = processStyleValue
Expand Down