diff --git a/packages/jest/test/__snapshots__/react-enzyme.test.js.snap b/packages/jest/test/__snapshots__/react-enzyme.test.js.snap index 9d18dffaa1..fbfd548ed9 100644 --- a/packages/jest/test/__snapshots__/react-enzyme.test.js.snap +++ b/packages/jest/test/__snapshots__/react-enzyme.test.js.snap @@ -7,9 +7,14 @@ exports[`enzyme mount basic 1`] = `
- hello + +
+ hello +
`; @@ -20,13 +25,14 @@ exports[`enzyme mount conditional styles 1`] = ` }
- +
- Test content - + +
`; @@ -36,13 +42,18 @@ exports[`enzyme mount displayName 1`] = ` } -
+ - Hello -
+
+ Hello +
+
`; @@ -65,9 +76,14 @@ exports[`enzyme mount nested 1`] = `
- hello + +
+ hello +
@@ -80,13 +96,18 @@ exports[`enzyme mount nested displayName 1`] = `
-
+ - Hello -
+
+ Hello +
+
`; @@ -120,14 +141,19 @@ exports[`enzyme mount nested styled with css prop 1`] = `
+ + +
`; @@ -158,14 +184,19 @@ exports[`enzyme mount styled with css prop 1`] = ` } + + + `; @@ -222,9 +253,14 @@ exports[`enzyme mount with array of styles as css prop 1`] = ` }
- Test content + +
+ Test content +
`; @@ -236,13 +272,18 @@ exports[`enzyme mount with array of styles in a composite inner child 1`] = `
- + - Test content - + + Test content + +
`; @@ -263,9 +304,14 @@ exports[`enzyme mount with prop containing css element 1`] = ` >

- Hello + +

+ Hello +

World! @@ -291,10 +337,16 @@ exports[`enzyme mount with prop containing css element not at the top level 1`] >

- Hello + +

+ Hello +

World! @@ -326,10 +378,16 @@ exports[`enzyme mount with prop containing css element with other label 1`] = ` } >

- Hello + +

+ Hello +

World! @@ -354,10 +412,16 @@ exports[`enzyme mount with prop containing css element with other props 1`] = ` >

- Hello + +

+ Hello +

World! @@ -385,13 +449,18 @@ exports[`enzyme mount with styles on top level 1`] = ` } -
+ - Hello -
+
+ Hello +
+
`; @@ -405,22 +474,28 @@ exports[`enzyme parent and child using css property 1`] = ` }
- Test content +
+ className="emotion-0" + > + Test content +
+ +
+
+
`; exports[`enzyme shallow basic 1`] = ` -.emotion-0 { - background-color: red; -} -
hello
@@ -431,15 +506,18 @@ exports[`enzyme shallow conditional styles 1`] = ` background-color: black; } -
- + +
- Test content - -
+ + Test content + +
+ `; exports[`enzyme shallow displayName 1`] = ` @@ -447,9 +525,12 @@ exports[`enzyme shallow displayName 1`] = ` color: hotpink; } - + + + + `; exports[`enzyme shallow empty styled 1`] = ` @@ -472,13 +553,9 @@ exports[`enzyme shallow nested 1`] = ` `; exports[`enzyme shallow nested displayName 1`] = ` -.emotion-0 { - color: hotpink; -} -
`; @@ -492,13 +569,9 @@ exports[`enzyme shallow nested styled 1`] = ` `; exports[`enzyme shallow nested styled with css prop 1`] = ` -.emotion-0 { - background-color: black; -} -
@@ -525,11 +598,14 @@ exports[`enzyme shallow styled with css prop 1`] = ` background-color: black; } - + + + + `; exports[`enzyme shallow theming 1`] = ` @@ -569,22 +645,20 @@ exports[`enzyme shallow with array of styles as css prop 1`] = ` color: white; } -
- Test content -
+ + +
+ Test content +
+
`; exports[`enzyme shallow with array of styles in a composite inner child 1`] = ` -.emotion-0 { - background-color: black; - color: white; -} -
Test content @@ -592,13 +666,9 @@ exports[`enzyme shallow with array of styles in a composite inner child 1`] = ` `; exports[`enzyme shallow with prop containing css element 1`] = ` -.emotion-0 { - background-color: blue; -} -

Hello

@@ -625,10 +695,6 @@ exports[`enzyme shallow with prop containing css element not at the top level 1` `; exports[`enzyme shallow with prop containing css element with other label 1`] = ` -.emotion-0 { - background-color: blue; -} -

Hello @@ -648,13 +714,9 @@ exports[`enzyme shallow with prop containing css element with other label 1`] = `; exports[`enzyme shallow with prop containing css element with other props 1`] = ` -.emotion-0 { - background-color: blue; -} -

Hello @@ -675,11 +737,14 @@ exports[`enzyme shallow with styles on top level 1`] = ` background-color: red; } - - Hello - + + + + Hello + + `; exports[`enzyme with prop containing css element in fragment 1`] = ` @@ -689,10 +754,13 @@ exports[`enzyme with prop containing css element in fragment 1`] = `

x -
- y -
+ Array [ + "", +
+ y +
, + ]
`; diff --git a/packages/react/src/class-names.js b/packages/react/src/class-names.js index 1ac618f3bb..deabcdce78 100644 --- a/packages/react/src/class-names.js +++ b/packages/react/src/class-names.js @@ -88,6 +88,8 @@ type Props = { }) => React.Node } +const Noop = () => null + export const ClassNames: React.AbstractComponent = /* #__PURE__ */ withEmotionCache((props, cache) => { let rules = '' @@ -125,21 +127,25 @@ export const ClassNames: React.AbstractComponent = } let ele = props.children(content) hasRendered = true + let possiblyStyleElement = if (!isBrowser && rules.length !== 0) { - return ( - <> -