feat(compiler): add isNativeTag option for determining element type (#139)

This commit is contained in:
月迷津渡
2019-10-11 02:54:06 +08:00
committed by Evan You
parent 46d875f4e8
commit 78f60347dc
7 changed files with 275 additions and 13 deletions

View File

@@ -5,6 +5,7 @@ import {
Namespaces,
NodeTypes
} from '@vue/compiler-core'
import { isVoidTag, isHTMLTag, isSVGTag } from '@vue/shared'
export const enum DOMNamespaces {
HTML = Namespaces.HTML,
@@ -13,6 +14,10 @@ export const enum DOMNamespaces {
}
export const parserOptionsMinimal: ParserOptions = {
isVoidTag,
isNativeTag: tag => isHTMLTag(tag) || isSVGTag(tag),
// https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher
getNamespace(tag: string, parent: ElementNode | undefined): DOMNamespaces {
let ns = parent ? parent.ns : DOMNamespaces.HTML
@@ -75,11 +80,5 @@ export const parserOptionsMinimal: ParserOptions = {
}
}
return TextModes.DATA
},
isVoidTag(tag: string): boolean {
return /^(?:area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/i.test(
tag
)
}
}