@@ -10,43 +10,64 @@ var _ = require('./index')
1010 */
1111
1212exports . 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 ) $ /
13- exports . checkComponent = function ( el , options ) {
13+ exports . checkComponent = function ( el , options , hasAttrs ) {
1414 var tag = el . tagName . toLowerCase ( )
15- if ( tag === 'component' ) {
16- // dynamic syntax
17- var exp = el . getAttribute ( 'is' )
18- if ( exp != null ) {
19- if ( process . env . NODE_ENV !== 'production' && / { { .* } } / . test ( exp ) ) {
20- _ . deprecation . BIND_IS ( )
21- }
22- el . removeAttribute ( 'is' )
23- } else {
24- exp = _ . getBindAttr ( el , 'is' )
25- if ( exp != null ) {
26- // leverage literal dynamic for now.
27- // TODO: make this cleaner
28- exp = '{{' + exp + '}}'
29- }
30- }
31- return exp
32- } else if ( ! exports . commonTagRE . test ( tag ) ) {
15+ if ( ! exports . commonTagRE . test ( tag ) && tag !== 'component' ) {
3316 if ( _ . resolveAsset ( options , 'components' , tag ) ) {
17+ // custom element component
3418 return tag
35- } else if ( process . env . NODE_ENV !== 'production' ) {
36- if ( tag . indexOf ( '-' ) > - 1 ||
37- / H T M L U n k n o w n E l e m e n t / . test ( Object . prototype . toString . call ( el ) ) ) {
38- _ . warn (
39- 'Unknown custom element: <' + tag + '> - did you ' +
40- 'register the component correctly?'
41- )
19+ } else {
20+ var exp = hasAttrs && checkComponentAttribute ( el )
21+ if ( exp ) return exp
22+ if ( process . env . NODE_ENV !== 'production' ) {
23+ if ( tag . indexOf ( '-' ) > - 1 ||
24+ / H T M L U n k n o w n E l e m e n t / . test ( Object . prototype . toString . call ( el ) ) ) {
25+ _ . warn (
26+ 'Unknown custom element: <' + tag + '> - did you ' +
27+ 'register the component correctly?'
28+ )
29+ }
4230 }
4331 }
32+ } else if ( hasAttrs ) {
33+ return checkComponentAttribute ( el )
4434 }
35+ }
36+
37+ /**
38+ * Check possible component denoting attributes, e.g.
39+ * is, bind-is and v-component.
40+ *
41+ * @param {Elemnent } el
42+ * @return {String|null }
43+ */
44+
45+ function checkComponentAttribute ( el ) {
46+ var exp
4547 /* eslint-disable no-cond-assign */
46- if ( tag = _ . attr ( el , 'component' ) ) {
48+ if ( exp = _ . attr ( el , 'component' ) ) {
4749 /* eslint-enable no-cond-assign */
48- return tag
50+ if ( process . env . NODE_ENV !== 'production' ) {
51+ _ . deprecation . V_COMPONENT ( )
52+ }
53+ return exp
54+ }
55+ // dynamic syntax
56+ exp = el . getAttribute ( 'is' )
57+ if ( exp != null ) {
58+ if ( process . env . NODE_ENV !== 'production' && / { { .* } } / . test ( exp ) ) {
59+ _ . deprecation . BIND_IS ( )
60+ }
61+ el . removeAttribute ( 'is' )
62+ } else {
63+ exp = _ . getBindAttr ( el , 'is' )
64+ if ( exp != null ) {
65+ // leverage literal dynamic for now.
66+ // TODO: make this cleaner
67+ exp = '{{' + exp + '}}'
68+ }
4969 }
70+ return exp
5071}
5172
5273/**
0 commit comments