fix(compiler-core): consistently remove comment nodes for pre tags in production

close #2217
This commit is contained in:
Evan You
2020-10-05 17:53:17 -04:00
parent 4d20ac8173
commit f4119249f2
2 changed files with 57 additions and 38 deletions

View File

@@ -384,6 +384,25 @@ describe('compiler: parse', () => {
expect(astNoComment.children).toHaveLength(0)
expect(astWithComments.children).toHaveLength(1)
})
// #2217
test('comments in the <pre> tag should be removed in production mode', () => {
__DEV__ = false
const rawText = `<p/><!-- foo --><p/>`
const ast = baseParse(`<pre>${rawText}</pre>`)
__DEV__ = true
expect((ast.children[0] as ElementNode).children).toMatchObject([
{
type: NodeTypes.ELEMENT,
tag: 'p'
},
{
type: NodeTypes.ELEMENT,
tag: 'p'
}
])
})
})
describe('Element', () => {