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:
@@ -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`)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user