跳到主要内容

is custom element

判定是否为自定义元素
function isCustomElement(tagName: string, props: Object): boolean {
if (tagName.indexOf('-') === -1) {
return false;
}
switch (tagName) {
// These are reserved SVG and MathML elements.
// We don't mind this list too much because we expect it to never grow.
// The alternative is to track the namespace in a few places which is convoluted.
// 这些是保留的 SVG 和 MathML 元素。
// 我们对这个列表并不太在意,因为我们预计它几乎不会增加。
// 另一种方法是在几个地方跟踪命名空间,这样会比较复杂。
// https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements-core-concepts
case 'annotation-xml':
case 'color-profile':
case 'font-face':
case 'font-face-src':
case 'font-face-uri':
case 'font-face-format':
case 'font-face-name':
case 'missing-glyph':
return false;
default:
return true;
}
}

export default isCustomElement;