@@ -64,21 +64,24 @@ function Compiler (vm, options) {
64
64
def ( vm , '$' , makeHash ( ) )
65
65
def ( vm , '$el' , el )
66
66
def ( vm , '$compiler' , compiler )
67
- def ( vm , '$root' , getRoot ( compiler ) . vm )
68
67
69
68
// set parent VM
70
69
// and register child id on parent
71
- var parent = compiler . parentCompiler ,
70
+ var parentVM = options . parent ,
72
71
childId = utils . attr ( el , 'ref' )
73
- if ( parent ) {
74
- parent . childCompilers . push ( compiler )
75
- def ( vm , '$parent' , parent . vm )
72
+ if ( parentVM ) {
73
+ compiler . parent = parentVM . $compiler
74
+ parentVM . $compiler . childCompilers . push ( compiler )
75
+ def ( vm , '$parent' , parentVM )
76
76
if ( childId ) {
77
77
compiler . childId = childId
78
- parent . vm . $ [ childId ] = vm
78
+ parentVM . $ [ childId ] = vm
79
79
}
80
80
}
81
81
82
+ // set root
83
+ def ( vm , '$root' , getRoot ( compiler ) . vm )
84
+
82
85
// setup observer
83
86
compiler . setupObserver ( )
84
87
@@ -546,7 +549,7 @@ CompilerProto.bindDirective = function (directive) {
546
549
if ( compiler . hasKey ( key ) ) {
547
550
break
548
551
} else {
549
- compiler = compiler . parentCompiler
552
+ compiler = compiler . parent
550
553
}
551
554
}
552
555
compiler = compiler || this
@@ -717,7 +720,7 @@ CompilerProto.markComputed = function (binding, value) {
717
720
*/
718
721
CompilerProto . getOption = function ( type , id ) {
719
722
var opts = this . options ,
720
- parent = this . parentCompiler ,
723
+ parent = this . parent ,
721
724
globalAssets = config . globalAssets
722
725
return ( opts [ type ] && opts [ type ] [ id ] ) || (
723
726
parent
@@ -844,8 +847,8 @@ CompilerProto.destroy = function () {
844
847
el . removeEventListener ( key , delegators [ key ] . handler )
845
848
}
846
849
847
- // remove self from parentCompiler
848
- var parent = compiler . parentCompiler ,
850
+ // remove self from parent
851
+ var parent = compiler . parent ,
849
852
childId = compiler . childId
850
853
if ( parent ) {
851
854
parent . childCompilers . splice ( parent . childCompilers . indexOf ( compiler ) , 1 )
@@ -877,8 +880,8 @@ CompilerProto.destroy = function () {
877
880
* shorthand for getting root compiler
878
881
*/
879
882
function getRoot ( compiler ) {
880
- while ( compiler . parentCompiler ) {
881
- compiler = compiler . parentCompiler
883
+ while ( compiler . parent ) {
884
+ compiler = compiler . parent
882
885
}
883
886
return compiler
884
887
}
0 commit comments