File tree 2 files changed +28
-1
lines changed
src/jsx/dom/intrinsic-element
2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -750,6 +750,33 @@ describe('intrinsic element', () => {
750
750
await Promise . resolve ( )
751
751
expect ( root . innerHTML ) . toBe ( '<div><div>Content</div><button>Show</button></div>' )
752
752
} )
753
+
754
+ it ( 'should be inserted into body if has no props' , async ( ) => {
755
+ const App = ( ) => {
756
+ return (
757
+ < div >
758
+ < script > alert('Hello')</ script >
759
+ </ div >
760
+ )
761
+ }
762
+ render ( < App /> , root )
763
+ expect ( document . head . innerHTML ) . toBe ( '' )
764
+ // prettier-ignore
765
+ expect ( root . innerHTML ) . toBe ( '<div><script>alert(\'Hello\')</script></div>' )
766
+ } )
767
+
768
+ it ( 'should be inserted into body if has only src prop' , async ( ) => {
769
+ const App = ( ) => {
770
+ return (
771
+ < div >
772
+ < script src = 'script.js' > </ script >
773
+ </ div >
774
+ )
775
+ }
776
+ render ( < App /> , root )
777
+ expect ( document . head . innerHTML ) . toBe ( '' )
778
+ expect ( root . innerHTML ) . toBe ( '<div><script src="script.js"></script></div>' )
779
+ } )
753
780
} )
754
781
755
782
it ( 'accept ref object' , async ( ) => {
Original file line number Diff line number Diff line change @@ -226,7 +226,7 @@ export const title: FC<PropsWithChildren> = (props) => {
226
226
export const script : FC < PropsWithChildren < IntrinsicElements [ 'script' ] > > = ( props ) => {
227
227
if ( ! props || [ 'src' , 'async' ] . some ( ( k ) => ! props [ k ] ) ) {
228
228
return newJSXNode ( {
229
- tag : 'style ' ,
229
+ tag : 'script ' ,
230
230
props,
231
231
} )
232
232
}
You can’t perform that action at this time.
0 commit comments