File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
test/unit/features/component Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,8 @@ export function generate (
4545 options : CompilerOptions
4646) : CodegenResult {
4747 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")'
4950 return {
5051 render : `with(this){return ${ code } }` ,
5152 staticRenderFns : state . staticRenderFns
Original file line number Diff line number Diff line change @@ -426,4 +426,17 @@ describe('Component', () => {
426426 vm . $destroy ( )
427427 } ) . then ( done )
428428 } )
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+ } )
429442} )
You can’t perform that action at this time.
0 commit comments