File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
test/unit/modules/compiler Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -442,7 +442,7 @@ export function genText (text: ASTText | ASTExpression): string {
442442}
443443
444444export function genComment ( comment : ASTText ) : string {
445- return `_e ( '${ comment . text } ' ) `
445+ return `_e ( ${ JSON . stringify ( comment . text ) } ) `
446446}
447447
448448function genSlot ( el : ASTElement , state : CodegenState ) : string {
Original file line number Diff line number Diff line change @@ -479,7 +479,21 @@ describe('codegen', () => {
479479 comments : true
480480 } , baseOptions )
481481 const template = '<div><!--comment--></div>'
482- const generatedCode = `with(this){return _c('div',[_e('comment')])}`
482+ const generatedCode = `with(this){return _c('div',[_e("comment")])}`
483+
484+ const ast = parse ( template , options )
485+ optimize ( ast , options )
486+ const res = generate ( ast , options )
487+ expect ( res . render ) . toBe ( generatedCode )
488+ } )
489+
490+ // #6150
491+ it ( 'generate comments with special characters' , ( ) => {
492+ const options = extend ( {
493+ comments : true
494+ } , baseOptions )
495+ const template = '<div><!--\n\'comment\'\n--></div>'
496+ const generatedCode = `with(this){return _c('div',[_e("\\n'comment'\\n")])}`
483497
484498 const ast = parse ( template , options )
485499 optimize ( ast , options )
You can’t perform that action at this time.
0 commit comments