Skip to content

Commit

Permalink
Fragment -> Noop
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Nov 9, 2021
1 parent e331b4e commit 92c1d28
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/jest/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function getClassNamesFromEnzyme(selectors, nodeWithFragment) {
// TODO: Does approach work with older Emotion versions? Does it cause false positives with components named "Fragment" that aren't `React.Fragment`?
const node =
nodeWithFragment.name() === 'Fragment'
? nodeWithFragment.children()
? nodeWithFragment.children().at(1)
: nodeWithFragment
// We need to dive in to get the className if we have a styled element from a shallow render
const isShallow = shouldDive(node)
Expand Down
9 changes: 9 additions & 0 deletions packages/jest/test/__snapshots__/react-enzyme.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ exports[`enzyme mount displayName 1`] = `

exports[`enzyme mount empty styled 1`] = `
<Greeting>
<Noop />
<div
className="emotion-0 emotion-1"
>
Expand Down Expand Up @@ -97,6 +98,7 @@ exports[`enzyme mount nested styled 1`] = `
<div>
<Greeting>
<Noop />
<div
className="emotion-0 emotion-1"
>
Expand All @@ -120,6 +122,7 @@ exports[`enzyme mount nested styled with css prop 1`] = `
<Button
className="emotion-0"
>
<Noop />
<button
className="emotion-1 emotion-2"
>
Expand All @@ -135,6 +138,7 @@ exports[`enzyme mount styled 1`] = `
}
<Greeting>
<Noop />
<div
className="emotion-0 emotion-1"
>
Expand All @@ -156,6 +160,7 @@ exports[`enzyme mount styled with css prop 1`] = `
<Button
className="emotion-0"
>
<Noop />
<button
className="emotion-1 emotion-2"
>
Expand All @@ -178,6 +183,7 @@ exports[`enzyme mount theming 1`] = `
}
}
>
<Noop />
<button
className="emotion-0 emotion-1"
>
Expand All @@ -198,6 +204,7 @@ exports[`enzyme mount theming 1`] = `
}
}
>
<Noop />
<button
className="emotion-0 emotion-1"
>
Expand Down Expand Up @@ -447,6 +454,7 @@ exports[`enzyme shallow displayName 1`] = `

exports[`enzyme shallow empty styled 1`] = `
<Fragment>
<Noop />
<div
className="emotion-0 emotion-1"
>
Expand Down Expand Up @@ -503,6 +511,7 @@ exports[`enzyme shallow styled 1`] = `
}
<Fragment>
<Noop />
<div
className="emotion-0 emotion-1"
>
Expand Down
3 changes: 2 additions & 1 deletion packages/styled/src/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ You can read more about this here:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#ES2018_revision_of_illegal_escape_sequences`

let isBrowser = typeof document !== 'undefined'
const Noop = () => null

let createStyled: CreateStyled = (tag: any, options?: StyledOptions) => {
if (process.env.NODE_ENV !== 'production') {
Expand Down Expand Up @@ -132,7 +133,7 @@ let createStyled: CreateStyled = (tag: any, options?: StyledOptions) => {
newProps.ref = ref

const ele = React.createElement(finalTag, newProps)
let possiblyStyleElement = <></>
let possiblyStyleElement = <Noop />
if (!isBrowser && rules !== undefined) {
let serializedNames = serialized.name
let next = serialized.next
Expand Down

0 comments on commit 92c1d28

Please sign in to comment.