8000 detect registered custom elements (fix #2345) · GCLluochen/vue@35e5a26 · GitHub
[go: up one dir, main page]

Skip to content

Commit 35e5a26

Browse files
committed
detect registered custom elements (fix vuejs#2345)
1 parent 0b907f7 commit 35e5a26

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

src/util/component.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,23 @@ import { isArray, isPlainObject } from './lang'
66
export const commonTagRE = /^(div|p|span|img|a|b|i|br|ul|ol|li|h1|h2|h3|h4|h5|h6|code|pre|table|th|td|tr|form|label|input|select|option|nav|article|section|header|footer)$/
77
export const reservedTagRE = /^(slot|partial|component)$/
88

9+
let isUnknownElement
10+
if (process.env.NODE_ENV !== 'production') {
11+
isUnknownElement = function (el, tag) {
12+
if (tag.indexOf('-') > -1) {
13+
// http://stackoverflow.com/a/28210364/1070244
14+
return el.constructor === window.HTMLElement
15+
} else {
16+
return (
17+
/HTMLUnknownElement/.test(el.toString()) &&
18+
// Chrome returns unknown for several HTML5 elements.
19+
// https://code.google.com/p/chromium/issues/detail?id=540526
20+
!/^(data|time|rtc|rb)$/.test(tag)
21+
)
22+
}
23+
}
24+
}
25+
926
/**
1027
* Check if an element is a component, if yes return its
1128
* component id.
@@ -26,15 +43,7 @@ export function checkComponentAttr (el, options) {
2643
if (is) {
2744
return is
2845
} else if (process.env.NODE_ENV !== 'production') {
29-
if (
30-
tag.indexOf('-') > -1 ||
31-
(
32-
/HTMLUnknownElement/.test(el.toString()) &&
33-
// Chrome returns unknown for several HTML5 elements.
34-
// https://code.google.com/p/chromium/issues/detail?id=540526
35-
!/^(data|time|rtc|rb)$/.test(tag)
36-
)
37-
) {
46+
if (isUnknownElement(el, tag)) {
3847
warn(
3948
'Unknown custom element: <' + tag + '> - did you ' +
4049
'register the component correctly? For recursive components, ' +

0 commit comments

Comments
 (0)
0