fix(compiler-dom): should ignore and warn side effect tags like script and style

This keeps behavior consistency with v2.
This commit is contained in:
Evan You
2020-07-08 12:32:07 -04:00
parent 903e8f697e
commit 5e52f4e4d7
4 changed files with 54 additions and 2 deletions

View File

@@ -0,0 +1,27 @@
import { compile, CompilerError } from '../../src'
describe('compiler: ignore side effect tags', () => {
it('should ignore script', () => {
let err: CompilerError | undefined
const { code } = compile(`<script>console.log(1)</script>`, {
onError(e) {
err = e
}
})
expect(code).not.toMatch('script')
expect(err).toBeDefined()
expect(err!.message).toMatch(`Tags with side effect`)
})
it('should ignore style', () => {
let err: CompilerError | undefined
const { code } = compile(`<style>h1 { color: red }</style>`, {
onError(e) {
err = e
}
})
expect(code).not.toMatch('style')
expect(err).toBeDefined()
expect(err!.message).toMatch(`Tags with side effect`)
})
})