File tree Expand file tree Collapse file tree 2 files changed +50
-2
lines changed Expand file tree Collapse file tree 2 files changed +50
-2
lines changed Original file line number Diff line number Diff line change @@ -87,4 +87,51 @@ describe('#jsx', () => {
8787 padding: 4px;
8888 ` )
8989 } )
90+
91+ it ( 'does not render children' , ( ) => {
92+ const { container } = render (
93+ < SpaceTheme >
94+ < div
95+ // @ts -expect-error
96+ css = { [ { margin : '2' } , { padding : '1' } ] }
97+ />
98+ </ SpaceTheme > ,
99+ )
100+
101+ expect ( container ) . toHaveTextContent ( '' )
102+ } )
103+
104+ it ( 'renders a single child' , ( ) => {
105+ const { container } = render (
106+ < SpaceTheme >
107+ < div
108+ // @ts -expect-error
109+ css = { [ { margin : '2' } , { padding : '1' } ] }
110+ >
111+ < p id = "test-p" > A testing paragraph</ p >
112+ </ div >
113+ </ SpaceTheme > ,
114+ )
115+
116+ expect ( container . querySelector ( '#test-p' ) ) . toHaveTextContent (
117+ 'A testing paragraph' ,
118+ )
119+ } )
120+
121+ it ( 'renders multiple children' , ( ) => {
122+ const { container } = render (
123+ < SpaceTheme >
124+ < div
125+ // @ts -expect-error
126+ css = { [ { margin : '2' } , { padding : '1' } ] }
127+ >
128+ < p className = "test-p" > First testing paragraph</ p >
129+
130+ < p className = "test-p" > Second testing paragraph</ p >
131+ </ div >
132+ </ SpaceTheme > ,
133+ )
134+
135+ expect ( container . querySelectorAll ( '.test-p' ) ) . toHaveLength ( 2 )
136+ } )
90137} )
Original file line number Diff line number Diff line change @@ -7,12 +7,13 @@ import { cx } from './cx'
77export const jsx : typeof emJsx = function (
88 type : React . ElementType ,
99 props ?: object ,
10+ ...children : React . ReactNode [ ]
1011) {
1112 if ( props == null || ! Object . prototype . hasOwnProperty . call ( props , 'css' ) ) {
1213 // @ts -expect-error
13- return React . createElement . apply ( undefined , arguments )
14+ return React . createElement . apply ( undefined , arguments , ... children )
1415 }
1516
1617 // @ts -expect-error
17- return emJsx ( type , { ...props , css : cx ( props . css ) } )
18+ return emJsx ( type , { ...props , css : cx ( props . css ) } , ... children )
1819}
You can’t perform that action at this time.
0 commit comments