Skip to content

Commit

Permalink
Fixed an issue with global styles containing pseudo selectors in at-r…
Browse files Browse the repository at this point in the history
…ules not being able to be inserted (#2180)
  • Loading branch information
Andarist committed Dec 20, 2020
1 parent 2f9ce55 commit 704b009
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .changeset/swift-hotels-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@emotion/cache': patch
'@emotion/css': patch
'@emotion/react': patch
---

Fixed an issue with global styles containing pseudo selectors in at-rules not being able to be inserted.
1 change: 1 addition & 0 deletions packages/cache/src/stylis-plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export let compat = element => {

while (parent.type !== 'rule') {
parent = parent.parent
if (!parent) return
}

// short-circuit for the simplest case
Expand Down
8 changes: 8 additions & 0 deletions packages/css/test/__snapshots__/inject-global.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ exports[`injectGlobal nested interpolated media query 1`] = `
}"
`;

exports[`injectGlobal pseudo in @media 1`] = `
"@media (min-width: 300px) {
.header:after {
content: '';
}
}"
`;

exports[`injectGlobal random interpolation 1`] = `
".css-1002tid-cls {
display: -webkit-box;
Expand Down
11 changes: 11 additions & 0 deletions packages/css/test/inject-global.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,15 @@ describe('injectGlobal', () => {
`
expect(sheet).toMatchSnapshot()
})
test('pseudo in @media', () => {
injectGlobal`
@media (min-width: 300px) {
.header:after {
content: '';
}
}
`

expect(sheet).toMatchSnapshot()
})
})

0 comments on commit 704b009

Please sign in to comment.