File tree 2 files changed +35
-1
lines changed
2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -333,7 +333,11 @@ export const parseStyle = (
333
333
if ( ! root ) {
334
334
styleStr = `{${ styleStr } }` ;
335
335
} else if ( layer ) {
336
- styleStr = `@layer ${ layer . name } {${ styleStr } }` ;
336
+
337
+ // fixme: https://github.com/thysultan/stylis/pull/339
338
+ if ( styleStr ) {
339
+ styleStr = `@layer ${ layer . name } {${ styleStr } }` ;
340
+ }
337
341
338
342
if ( layer . dependencies ) {
339
343
effectStyle [ `@layer ${ layer . name } ` ] = layer . dependencies
Original file line number Diff line number Diff line change @@ -66,4 +66,34 @@ describe('layer', () => {
66
66
const styles = Array . from ( document . head . querySelectorAll ( 'style' ) ) ;
67
67
expect ( styles [ 0 ] . innerHTML . trim ( ) ) . toEqual ( '@layer shared,button;' ) ;
68
68
} ) ;
69
+
70
+ // TODO: try fix, If stylis is fixed, this case should not be needed here.
71
+ // https://github.com/thysultan/stylis/pull/339
72
+ // https://github.com/ant-design/ant-design/issues/51867
73
+ it ( 'empty braces (#51867)' , ( ) => {
74
+ const theme = createTheme ( ( ) => ( { } ) ) ;
75
+ const Demo = ( ) => {
76
+ useStyleRegister (
77
+ {
78
+ theme,
79
+ token : { _tokenKey : 'test' } ,
80
+ path : [ 'shared' ] ,
81
+ layer : {
82
+ name : 'shared' ,
83
+ } ,
84
+ } ,
85
+ ( ) => [ ] ,
86
+ ) ;
87
+ return null ;
88
+ } ;
89
+
90
+ render (
91
+ < StyleProvider layer cache = { createCache ( ) } >
92
+ < Demo />
93
+ </ StyleProvider > ,
94
+ ) ;
95
+
96
+ const styles = Array . from ( document . head . querySelectorAll ( 'style' ) ) ;
97
+ expect ( styles [ 0 ] . innerHTML . trim ( ) ) . toEqual ( '' ) ;
98
+ } ) ;
69
99
} ) ;
You can’t perform that action at this time.
0 commit comments