@@ -64,21 +64,24 @@ function Compiler (vm, options) {
6464 def ( vm , '$' , makeHash ( ) )
6565 def ( vm , '$el' , el )
6666 def ( vm , '$compiler' , compiler )
67- def ( vm , '$root' , getRoot ( compiler ) . vm )
6867
6968 // set parent VM
7069 // and register child id on parent
71- var parent = compiler . parentCompiler ,
70+ var parentVM = options . parent ,
7271 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 )
7676 if ( childId ) {
7777 compiler . childId = childId
78- parent . vm . $ [ childId ] = vm
78+ parentVM . $ [ childId ] = vm
7979 }
8080 }
8181
82+ // set root
83+ def ( vm , '$root' , getRoot ( compiler ) . vm )
84+
8285 // setup observer
8386 compiler . setupObserver ( )
8487
@@ -546,7 +549,7 @@ CompilerProto.bindDirective = function (directive) {
546549 if ( compiler . hasKey ( key ) ) {
547550 break
548551 } else {
549- compiler = compiler . parentCompiler
552+ compiler = compiler . parent
550553 }
551554 }
552555 compiler = compiler || this
@@ -717,7 +720,7 @@ CompilerProto.markComputed = function (binding, value) {
717720 */
718721CompilerProto . getOption = function ( type , id ) {
719722 var opts = this . options ,
720- parent = this . parentCompiler ,
723+ parent = this . parent ,
721724 globalAssets = config . globalAssets
722725 return ( opts [ type ] && opts [ type ] [ id ] ) || (
723726 parent
@@ -844,8 +847,8 @@ CompilerProto.destroy = function () {
844847 el . removeEventListener ( key , delegators [ key ] . handler )
845848 }
846849
847- // remove self from parentCompiler
848- var parent = compiler . parentCompiler ,
850+ // remove self from parent
851+ var parent = compiler . parent ,
849852 childId = compiler . childId
850853 if ( parent ) {
851854 parent . childCompilers . splice ( parent . childCompilers . indexOf ( compiler ) , 1 )
@@ -877,8 +880,8 @@ CompilerProto.destroy = function () {
877880 * shorthand for getting root compiler
878881 */
879882function getRoot ( compiler ) {
880- while ( compiler . parentCompiler ) {
881- compiler = compiler . parentCompiler
883+ while ( compiler . parent ) {
884+ compiler = compiler . parent
882885 }
883886 return compiler
884887}
0 commit comments