Skip to content

Commit c02b121

Browse files
authoredSep 15, 2022
Fixed an issue that prevented using content: "element(name)" (#2896)
1 parent 5fa2d54 commit c02b121

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed
 

‎.changeset/rude-bats-check.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@emotion/serialize': patch
3+
---
4+
5+
Fixed an issue that prevented using `content: "element(name)"`. This is a valid special value and doesn't need to be quoted.

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

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ exports[`does not warn when valid values are passed for the content property 1`]
2323
content: counters(section_counter, ".");
2424
content: attr(value string);
2525
content: open-quote counter(chapter_counter);
26+
content: element(name);
2627
}
2728
2829
<div

‎packages/react/__tests__/warnings.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ const validValues = [
3030
'counter(chapter_counter)',
3131
'counters(section_counter, ".")',
3232
'attr(value string)',
33-
'open-quote counter(chapter_counter)'
33+
'open-quote counter(chapter_counter)',
34+
// https://github.com/emotion-js/emotion/issues/2895
35+
'element(name)'
3436
]
3537

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

46-
const invalidValues = ['this is not valid', '']
48+
const invalidValues = ['this is not valid', '', 'element']
4749

4850
it('does warn when invalid values are passed for the content property', () => {
4951
// $FlowFixMe

‎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-
/(var|attr|counters?|url|(((repeating-)?(linear|radial))|conic)-gradient)\(|(no-)?(open|close)-quote/
64+
/(var|attr|counters?|url|element|(((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)
Please sign in to comment.