File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed
Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -27,16 +27,22 @@ function Template(props) {
2727 }
2828
2929 const otherProps = omit ( props , keys ( Template . propTypes ) ) ;
30- const isElement = React . isValidElement ( content ) ;
30+
31+ if ( React . isValidElement ( content ) ) {
32+ return (
33+ < div
34+ { ...otherProps }
35+ className = { props . cssClass }
36+ > { content } </ div >
37+ ) ;
38+ }
3139
3240 return (
3341 < div
3442 { ...otherProps }
3543 className = { props . cssClass }
36- dangerouslySetInnerHTML = { isElement ? null : { __html : content } }
37- >
38- { isElement ? content : null }
39- </ div >
44+ dangerouslySetInnerHTML = { { __html : content } }
45+ />
4046 ) ;
4147}
4248
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ describe('Template', () => {
5454 const out = renderer . getRenderOutput ( ) ;
5555
5656 const content = 'it also works with functions' ;
57- expect ( out ) . toEqualJSX ( < div className = { undefined } dangerouslySetInnerHTML = { null } > < p > { content } </ p > </ div > ) ;
57+ expect ( out ) . toEqualJSX ( < div className = { undefined } > < p > { content } </ p > </ div > ) ;
5858 } ) ;
5959
6060 it ( 'can configure compilation options' , ( ) => {
You can’t perform that action at this time.
0 commit comments