diff --git a/packages/emotion/src/index.js b/packages/emotion/src/index.js index 669040877..82c4bf6f2 100644 --- a/packages/emotion/src/index.js +++ b/packages/emotion/src/index.js @@ -198,10 +198,7 @@ function isLastCharDot(string) { function createStyles(strings, ...interpolations) { let stringMode = true let styles = '' - if ( - (strings !== undefined && strings.raw === undefined) || - strings === undefined - ) { + if (strings == null || strings === undefined || strings.raw === undefined) { stringMode = false styles = handleInterpolation(strings, false) } else { diff --git a/packages/emotion/test/__snapshots__/css.test.js.snap b/packages/emotion/test/__snapshots__/css.test.js.snap index f3816a88f..6740c5018 100644 --- a/packages/emotion/test/__snapshots__/css.test.js.snap +++ b/packages/emotion/test/__snapshots__/css.test.js.snap @@ -399,6 +399,18 @@ exports[`css null rule 1`] = ` /> `; +exports[`css null value 1`] = ` +
+`; + +exports[`css null value 2`] = ` + +`; + exports[`css random expression 1`] = ` .glamor-0 { font-size: 20px; diff --git a/packages/emotion/test/css.test.js b/packages/emotion/test/css.test.js index f26037f7f..264230d2b 100644 --- a/packages/emotion/test/css.test.js +++ b/packages/emotion/test/css.test.js @@ -281,6 +281,14 @@ describe('css', () => { const tree = renderer.create().toJSON() expect(tree).toMatchSnapshot() }) + + test('null value', () => { + const cls1 = css(null) + const cls2 = css`${() => null};` + expect(renderer.create().toJSON()).toMatchSnapshot() + expect(renderer.create().toJSON()).toMatchSnapshot() + }) + test('flushes correctly', () => { const cls1 = css`display: flex;` const tree = renderer.create().toJSON() diff --git a/packages/react-emotion/test/__snapshots__/index.test.js.snap b/packages/react-emotion/test/__snapshots__/index.test.js.snap index 7b620f573..8462afbf0 100644 --- a/packages/react-emotion/test/__snapshots__/index.test.js.snap +++ b/packages/react-emotion/test/__snapshots__/index.test.js.snap @@ -447,6 +447,31 @@ exports[`styled no prop filtering on non string tags 1`] = ` `; +exports[`styled null interpolation value 1`] = ` +.glamor-0 { + color: blue; + font-size: 20; +} + +@media (min-width:520px) { + .glamor-0 { + color: green; + } +} + +@media (min-width:420px) { + .glamor-0 { + color: blue; + } +} + +