@@ -109,82 +109,74 @@ const Insertion = ({
109109 return null
110110}
111111
112- let Emotion = /* #__PURE__ */ withEmotionCache < EmotionProps > (
113- ( props , cache , ref ) => {
114- let cssProp = props . css as EmotionProps [ 'css' ]
115-
116- // so that using `css` from `emotion` and passing the result to the css prop works
117- // not passing the registered cache to serializeStyles because it would
118- // make certain babel optimisations not possible
119- if (
120- typeof cssProp === 'string' &&
121- cache . registered [ cssProp ] !== undefined
122- ) {
123- cssProp = cache . registered [ cssProp ]
124- }
112+ let Emotion = /* #__PURE__ */ withEmotionCache < EmotionProps > ( ( props , cache ) => {
113+ let cssProp = props . css as EmotionProps [ 'css' ]
114+
115+ // so that using `css` from `emotion` and passing the result to the css prop works
116+ // not passing the registered cache to serializeStyles because it would
117+ // make certain babel optimisations not possible
118+ if ( typeof cssProp === 'string' && cache . registered [ cssProp ] !== undefined ) {
119+ cssProp = cache . registered [ cssProp ]
120+ }
125121
126- let WrappedComponent = props [
127- typePropName
128- ] as EmotionProps [ typeof typePropName ]
129- let registeredStyles = [ cssProp ]
130- let className = ''
131-
132- if ( typeof props . className === 'string' ) {
133- className = getRegisteredStyles (
134- cache . registered ,
135- registeredStyles ,
136- props . className
137- )
138- } else if ( props . className != null ) {
139- className = `${ props . className } `
140- }
122+ let WrappedComponent = props [
123+ typePropName
124+ ] as EmotionProps [ typeof typePropName ]
125+ let registeredStyles = [ cssProp ]
126+ let className = ''
141127
142- let serialized = serializeStyles (
128+ if ( typeof props . className === 'string' ) {
129+ className = getRegisteredStyles (
130+ cache . registered ,
143131 registeredStyles ,
144- undefined ,
145- React . useContext ( ThemeContext )
132+ props . className
146133 )
134+ } else if ( props . className != null ) {
135+ className = `${ props . className } `
136+ }
147137
148- if ( isDevelopment && serialized . name . indexOf ( '-' ) === - 1 ) {
149- let labelFromStack = props [ labelPropName ]
150- if ( labelFromStack ) {
151- serialized = serializeStyles ( [
152- serialized ,
153- 'label:' + labelFromStack + ';'
154- ] )
155- }
156- }
138+ let serialized = serializeStyles (
139+ registeredStyles ,
140+ undefined ,
141+ React . useContext ( ThemeContext )
142+ )
157143
158- className += `${ cache . key } -${ serialized . name } `
159-
160- const newProps : Record < string , unknown > = { }
161- for ( let key in props ) {
162- if (
163- hasOwn . call ( props , key ) &&
164- key !== 'css' &&
165- key !== typePropName &&
166- ( ! isDevelopment || key !== labelPropName )
167- ) {
168- newProps [ key ] = props [ key ]
169- }
170- }
171- newProps . className = className
172- if ( ref ) {
173- newProps . ref = ref
144+ if ( isDevelopment && serialized . name . indexOf ( '-' ) === - 1 ) {
145+ let labelFromStack = props [ labelPropName ]
146+ if ( labelFromStack ) {
147+ serialized = serializeStyles ( [
148+ serialized ,
149+ 'label:' + labelFromStack + ';'
150+ ] )
174151 }
152+ }
175153
176- return (
177- < >
178- < Insertion
179- cache = { cache }
180- serialized = { serialized }
181- isStringTag = { typeof WrappedComponent === 'string' }
182- />
183- < WrappedComponent { ...newProps } />
184- </ >
185- )
154+ className += `${ cache . key } -${ serialized . name } `
155+
156+ const newProps : Record < string , unknown > = { }
157+ for ( let key in props ) {
158+ if (
159+ hasOwn . call ( props , key ) &&
160+ key !== 'css' &&
161+ key !== typePropName &&
162+ ( ! isDevelopment || key !== labelPropName )
163+ ) {
164+ newProps [ key ] = props [ key ]
165+ }
186166 }
187- )
167+ newProps . className = className
168+
169+ return (
170+ < >
171+ < Insertion
172+ cache = { cache }
173+ serialized = { serialized }
174+ isStringTag = { typeof WrappedComponent === 'string' }
175+ />
176+ < WrappedComponent { ...newProps } />
177+ </ >
178+ )
179+ } )
188180
189181if ( isDevelopment ) {
190182 Emotion . displayName = 'EmotionCssPropInternal'
0 commit comments