@@ -30,9 +30,12 @@ var Emitter = require('./emitter'),
3030function Compiler ( vm , options ) {
3131
3232 var compiler = this
33- // indicate that we are intiating this instance
34- // so we should not run any transitions
35- compiler . init = true
33+
34+ // default state
35+ compiler . init = true
36+ compiler . repeat = false
37+ compiler . destroyed = false
38+ compiler . delayReady = false
3639
3740 // process and extend options
3841 options = compiler . options = options || makeHash ( )
@@ -55,7 +58,7 @@ function Compiler (vm, options) {
5558 compiler . deferred = [ ]
5659 compiler . exps = [ ]
5760 compiler . computed = [ ]
58- compiler . childCompilers = [ ]
61+ compiler . children = [ ]
5962 compiler . emitter = new Emitter ( )
6063 compiler . emitter . _ctx = vm
6164 compiler . delegators = makeHash ( )
@@ -71,7 +74,7 @@ function Compiler (vm, options) {
7174 childId = utils . attr ( el , 'ref' )
7275 if ( parentVM ) {
7376 compiler . parent = parentVM . $compiler
74- parentVM . $compiler . childCompilers . push ( compiler )
77+ parentVM . $compiler . children . push ( compiler )
7578 def ( vm , '$parent' , parentVM )
7679 if ( childId ) {
7780 compiler . childId = childId
@@ -254,7 +257,7 @@ CompilerProto.setupObserver = function () {
254257 }
255258
256259 function broadcast ( event ) {
257- var children = compiler . childCompilers
260+ var children = compiler . children
258261 if ( children ) {
259262 var child , i = children . length
260263 while ( i -- ) {
@@ -806,7 +809,9 @@ CompilerProto.destroy = function () {
806809 directives = compiler . dirs ,
807810 exps = compiler . exps ,
808811 bindings = compiler . bindings ,
809- delegators = compiler . delegators
812+ delegators = compiler . delegators ,
813+ children = compiler . children ,
814+ parent = compiler . parent
810815
811816 compiler . execHook ( 'beforeDestroy' )
812817
@@ -847,13 +852,17 @@ CompilerProto.destroy = function () {
847852 el . removeEventListener ( key , delegators [ key ] . handler )
848853 }
849854
855+ // destroy all children
856+ i = children . length
857+ while ( i -- ) {
858+ children [ i ] . destroy ( )
859+ }
860+
850861 // remove self from parent
851- var parent = compiler . parent ,
852- childId = compiler . childId
853862 if ( parent ) {
854- parent . childCompilers . splice ( parent . childCompilers . indexOf ( compiler ) , 1 )
855- if ( childId ) {
856- delete parent . vm . $ [ childId ]
863+ parent . children . splice ( parent . children . indexOf ( compiler ) , 1 )
864+ if ( compiler . childId ) {
865+ delete parent . vm . $ [ compiler . childId ]
857866 }
858867 }
859868
0 commit comments