@@ -6,6 +6,23 @@ import { isArray, isPlainObject } from './lang'
6
6
export const commonTagRE = / ^ ( d i v | p | s p a n | i m g | a | b | i | b r | u l | o l | l i | h 1 | h 2 | h 3 | h 4 | h 5 | h 6 | c o d e | p r e | t a b l e | t h | t d | t r | f o r m | l a b e l | i n p u t | s e l e c t | o p t i o n | n a v | a r t i c l e | s e c t i o n | h e a d e r | f o o t e r ) $ /
7
7
export const reservedTagRE = / ^ ( s l o t | p a r t i a l | c o m p o n e n t ) $ /
8
8
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
+ / H T M L U n k n o w n E l e m e n t / . test ( el . toString ( ) ) &&
18
+ // Chrome returns unknown for several HTML5 elements.
19
+ // https://code.google.com/p/chromium/issues/detail?id=540526
20
+ ! / ^ ( d a t a | t i m e | r t c | r b ) $ / . test ( tag )
21
+ )
22
+ }
23
+ }
24
+ }
25
+
9
26
/**
10
27
* Check if an element is a component, if yes return its
11
28
* component id.
@@ -26,15 +43,7 @@ export function checkComponentAttr (el, options) {
26
43
if ( is ) {
27
44
return is
28
45
} else if ( process . env . NODE_ENV !== 'production' ) {
29
- if (
30
- tag . indexOf ( '-' ) > - 1 ||
31
- (
32
- / H T M L U n k n o w n E l e m e n t / . test ( el . toString ( ) ) &&
33
- // Chrome returns unknown for several HTML5 elements.
34
- // https://code.google.com/p/chromium/issues/detail?id=540526
35
- ! / ^ ( d a t a | t i m e | r t c | r b ) $ / . test ( tag )
36
- )
37
- ) {
46
+ if ( isUnknownElement ( el , tag ) ) {
38
47
warn (
39
48
'Unknown custom element: <' + tag + '> - did you ' +
40
49
'register the component correctly? For recursive components, ' +
0 commit comments