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,15 @@
import { NodeTransform, NodeTypes, ElementTypes } from '@vue/compiler-core/src'
import { DOMErrorCodes, createDOMCompilerError } from '../errors'
export const ignoreSideEffectTags: NodeTransform = (node, context) => {
if (
node.type === NodeTypes.ELEMENT &&
node.tagType === ElementTypes.ELEMENT &&
(node.tag === 'script' || node.tag === 'style')
) {
context.onError(
createDOMCompilerError(DOMErrorCodes.X_IGNORED_SIDE_EFFECT_TAG, node.loc)
)
context.removeNode()
}
}