Skip to content

Commit

Permalink
Fixed an issue that prevented using content: "element(name)" (#2896)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed Sep 15, 2022
1 parent 5fa2d54 commit c02b121
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
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

0 comments on commit c02b121

Please sign in to comment.