File tree 2 files changed +15
-1
lines changed
test/unit/features/component
2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,8 @@ export function generate (
45
45
options : CompilerOptions
46
46
) : CodegenResult {
47
47
const state = new CodegenState ( options )
48
- const code = ast ? genElement ( ast , state ) : '_c("div")'
48
+ // fix #11483, Root level <script> tags should not be rendered.
49
+ const code = ast ? ( ast . tag === 'script' ? 'null' : genElement ( ast , state ) ) : '_c("div")'
49
50
return {
50
51
render : `with(this){return ${ code } }` ,
51
52
staticRenderFns : state . staticRenderFns
Original file line number Diff line number Diff line change @@ -426,4 +426,17 @@ describe('Component', () => {
426
426
vm . $destroy ( )
427
427
} ) . then ( done )
428
428
} )
429
+
430
+ it ( 'render vnode with <script> tag as root element' , ( ) => {
431
+ const vm = new Vue ( {
432
+ template : '<scriptTest></scriptTest>' ,
433
+ components : {
434
+ scriptTest : {
435
+ template : '<script>console.log(1)</script>'
436
+ }
437
+ }
438
+ } ) . $mount ( )
439
+ expect ( vm . $el . nodeName ) . toBe ( '#comment' )
440
+ expect ( 'Templates should only be responsible for mapping the state' ) . toHaveBeenWarned ( )
441
+ } )
429
442
} )
You can’t perform that action at this time.
0 commit comments