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

Fixed an issue that prevented using content: "element(name)" #2896

Merged
merged 1 commit into from Sep 15, 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
5 changes: 5 additions & 0 deletions .changeset/rude-bats-check.md
@@ -0,0 +1,5 @@
---
'@emotion/serialize': patch
---

Fixed an issue that prevented using `content: "element(name)"`. This is a valid special value and doesn't need to be quoted.
1 change: 1 addition & 0 deletions packages/react/__tests__/__snapshots__/warnings.js.snap
Expand Up @@ -23,6 +23,7 @@ exports[`does not warn when valid values are passed for the content property 1`]
content: counters(section_counter, ".");
content: attr(value string);
content: open-quote counter(chapter_counter);
content: element(name);
}

<div
Expand Down
6 changes: 4 additions & 2 deletions packages/react/__tests__/warnings.js
Expand Up @@ -30,7 +30,9 @@ const validValues = [
'counter(chapter_counter)',
'counters(section_counter, ".")',
'attr(value string)',
'open-quote counter(chapter_counter)'
'open-quote counter(chapter_counter)',
// https://github.com/emotion-js/emotion/issues/2895
'element(name)'
]

beforeEach(() => {
Expand All @@ -43,7 +45,7 @@ it('does not warn when valid values are passed for the content property', () =>
expect(renderer.create(<div css={style} />).toJSON()).toMatchSnapshot()
})

const invalidValues = ['this is not valid', '']
const invalidValues = ['this is not valid', '', 'element']

it('does warn when invalid values are passed for the content property', () => {
// $FlowFixMe
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 =
/(var|attr|counters?|url|(((repeating-)?(linear|radial))|conic)-gradient)\(|(no-)?(open|close)-quote/
/(var|attr|counters?|url|element|(((repeating-)?(linear|radial))|conic)-gradient)\(|(no-)?(open|close)-quote/
let contentValues = ['normal', 'none', 'initial', 'inherit', 'unset']

let oldProcessStyleValue = processStyleValue
Expand Down