@@ -65,33 +65,27 @@ function compileNode (node, options) {
65
65
*/
66
66
67
67
function compileElement ( el , options ) {
68
- var hasAttributes = el . hasAttributes ( )
69
- var tag = el . tagName . toLowerCase ( )
70
- if ( hasAttributes ) {
71
- // check terminal direcitves
72
- var terminalLinkFn
73
- for ( var i = 0 ; i < 3 ; i ++ ) {
74
- terminalLinkFn = checkTerminalDirectives ( el , options )
75
- if ( terminalLinkFn ) {
76
- terminalLinkFn . terminal = true
77
- return terminalLinkFn
78
- }
68
+ var linkFn , tag , component
69
+ // check custom element component, but only on non-root
70
+ if ( ! el . __vue__ ) {
71
+ tag = el . tagName . toLowerCase ( )
72
+ component =
73
+ tag . indexOf ( '-' ) > 0 &&
74
+ options . components [ tag ]
75
+ if ( component ) {
76
+ el . setAttribute ( config . prefix + 'component' , tag )
79
77
}
80
78
}
81
- // check custom element component
82
- var component =
83
- tag . indexOf ( '-' ) > 0 &&
84
- options . components [ tag ]
85
- if ( component ) {
86
- return makeTeriminalLinkFn ( el , 'component' , tag , options )
87
- }
88
- // check other directives
89
- var linkFn
90
- if ( hasAttributes ) {
91
- var directives = collectDirectives ( el , options )
92
- linkFn = directives . length
93
- ? makeDirectivesLinkFn ( directives )
94
- : null
79
+ if ( component || el . hasAttributes ( ) ) {
80
+ // check terminal direcitves
81
+ linkFn = checkTerminalDirectives ( el , options )
82
+ // if not terminal, build normal link function
83
+ if ( ! linkFn ) {
84
+ var directives = collectDirectives ( el , options )
85
+ linkFn = directives . length
86
+ ? makeDirectivesLinkFn ( directives )
87
+ : null
88
+ }
95
89
}
96
90
// if the element is a textarea, we need to interpolate
97
91
// its content on initial render.
@@ -101,6 +95,7 @@ function compileElement (el, options) {
101
95
el . value = vm . $interpolate ( el . value )
102
96
if ( realLinkFn ) realLinkFn ( vm , el )
103
97
}
98
+ linkFn . terminal = true
104
99
}
105
100
return linkFn
106
101
}
@@ -388,9 +383,11 @@ function checkTerminalDirectives (el, options) {
388
383
function makeTeriminalLinkFn ( el , dirName , value , options ) {
389
384
var descriptor = dirParser . parse ( value ) [ 0 ]
390
385
var def = options . directives [ dirName ]
391
- return function terminalLinkFn ( vm , el ) {
386
+ var terminalLinkFn = function ( vm , el ) {
392
387
vm . _bindDir ( dirName , el , descriptor , def )
393
388
}
389
+ terminalLinkFn . terminal = true
390
+ return terminalLinkFn
394
391
}
395
392
396
393
/**
0 commit comments