|
@@ -1,7 +1,7 @@
|
|
|
import { parse } from 'compiler/parser/index'
|
|
import { parse } from 'compiler/parser/index'
|
|
|
import { optimize } from 'compiler/optimizer'
|
|
import { optimize } from 'compiler/optimizer'
|
|
|
import { generate } from 'compiler/codegen'
|
|
import { generate } from 'compiler/codegen'
|
|
|
-import { isObject } from 'shared/util'
|
|
|
|
|
|
|
+import { isObject, extend } from 'shared/util'
|
|
|
import { isReservedTag } from 'web/util/index'
|
|
import { isReservedTag } from 'web/util/index'
|
|
|
import { baseOptions } from 'web/compiler/options'
|
|
import { baseOptions } from 'web/compiler/options'
|
|
|
|
|
|
|
@@ -474,6 +474,19 @@ describe('codegen', () => {
|
|
|
)
|
|
)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ it('generate component with comment', () => {
|
|
|
|
|
+ const options = extend({
|
|
|
|
|
+ comments: true
|
|
|
|
|
+ }, baseOptions)
|
|
|
|
|
+ const template = '<div><!--comment--></div>'
|
|
|
|
|
+ const generatedCode = `with(this){return _c('div',[_e('comment')])}`
|
|
|
|
|
+
|
|
|
|
|
+ const ast = parse(template, options)
|
|
|
|
|
+ optimize(ast, options)
|
|
|
|
|
+ const res = generate(ast, options)
|
|
|
|
|
+ expect(res.render).toBe(generatedCode)
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
it('not specified ast type', () => {
|
|
it('not specified ast type', () => {
|
|
|
const res = generate(null, baseOptions)
|
|
const res = generate(null, baseOptions)
|
|
|
expect(res.render).toBe(`with(this){return _c("div")}`)
|
|
expect(res.render).toBe(`with(this){return _c("div")}`)
|