|
1 | 1 | import prettify from '@emotion/css-prettifier'
|
2 | 2 | import { replaceClassNames } from './replace-class-names'
|
3 |
| -import * as enzymeTickler from './enzyme-tickler' |
4 | 3 | import {
|
5 | 4 | getClassNamesFromNodes,
|
6 | 5 | isReactElement,
|
7 | 6 | isEmotionCssPropElementType,
|
8 |
| - isEmotionCssPropEnzymeElement, |
9 | 7 | isDOMElement,
|
10 | 8 | getStylesFromClassNames,
|
11 | 9 | getStyleElements,
|
@@ -102,49 +100,11 @@ function getLabelsFromClassName(keys, className) {
|
102 | 100 | }).filter(Boolean)
|
103 | 101 | }
|
104 | 102 |
|
105 |
| -function isShallowEnzymeElement( |
106 |
| - element /*: any */, |
107 |
| - keys /*: string[] */, |
108 |
| - labels /*: string[] */ |
109 |
| -) { |
110 |
| - const childClassNames = (element.children || []) |
111 |
| - .map(({ props = {} }) => props.className || '') |
112 |
| - .filter(Boolean) |
113 |
| - |
114 |
| - return !childClassNames.some(className => { |
115 |
| - const childLabels = getLabelsFromClassName(keys, className) |
116 |
| - return childLabels.every(childLabel => labels.includes(childLabel)) |
117 |
| - }) |
118 |
| -} |
119 |
| - |
120 | 103 | const createConvertEmotionElements =
|
121 | 104 | (keys /*: string[]*/) => (node /*: any*/) => {
|
122 | 105 | if (isPrimitive(node)) {
|
123 | 106 | return node
|
124 | 107 | }
|
125 |
| - if (isEmotionCssPropEnzymeElement(node)) { |
126 |
| - const className = enzymeTickler.getTickledClassName(node.props.css) |
127 |
| - const labels = getLabelsFromClassName(keys, className || '') |
128 |
| - |
129 |
| - if (isShallowEnzymeElement(node, keys, labels)) { |
130 |
| - const emotionType = node.props.__EMOTION_TYPE_PLEASE_DO_NOT_USE__ |
131 |
| - // emotionType will be a string for DOM elements |
132 |
| - const type = |
133 |
| - typeof emotionType === 'string' |
134 |
| - ? emotionType |
135 |
| - : emotionType.displayName || emotionType.name || 'Component' |
136 |
| - return { |
137 |
| - ...node, |
138 |
| - props: filterEmotionProps({ |
139 |
| - ...node.props, |
140 |
| - className |
141 |
| - }), |
142 |
| - type |
143 |
| - } |
144 |
| - } else { |
145 |
| - return node.children[node.children.length - 1] |
146 |
| - } |
147 |
| - } |
148 | 108 | if (isEmotionCssPropElementType(node)) {
|
149 | 109 | return {
|
150 | 110 | ...node,
|
|
0 commit comments