@@ -64,12 +64,12 @@ export default function Fragment (linker, vm, frag, host, scope, parentFrag) {
6464
6565Fragment . prototype . callHook = function ( hook ) {
6666 var i , l
67- for ( i = 0 , l = this . children . length ; i < l ; i ++ ) {
68- hook ( this . children [ i ] )
69- }
7067 for ( i = 0 , l = this . childFrags . length ; i < l ; i ++ ) {
7168 this . childFrags [ i ] . callHook ( hook )
7269 }
70+ for ( i = 0 , l = this . children . length ; i < l ; i ++ ) {
71+ hook ( this . children [ i ] )
72+ }
7373}
7474
7575/**
@@ -147,16 +147,28 @@ function multiRemove () {
147147
148148/**
149149 * Prepare the fragment for removal.
150- * Most importantly, disable the watchers on all the
151- * directives so that the rendered content stays the same
152- * during removal.
153150 */
154151
155152Fragment . prototype . beforeRemove = function ( ) {
156- this . callHook ( destroyChild )
153+ var i , l
154+ for ( i = 0 , l = this . childFrags . length ; i < l ; i ++ ) {
155+ // call the same method recursively on child
156+ // fragments, depth-first
157+ this . childFrags [ i ] . beforeRemove ( false )
158+ }
159+ for ( i = 0 , l = this . children . length ; i < l ; i ++ ) {
160+ // Call destroy for all contained instances,
161+ // with remove:false and defer:true.
162+ // Defer is necessary because we need to
163+ // keep the children to call detach hooks
164+ // on them.
165+ this . children [ i ] . $destroy ( false , true )
166+ }
157167 var dirs = this . unlink . dirs
158- var i = dirs . length
159- while ( i -- ) {
168+ for ( i = 0 , l = dirs . length ; i < l ; i ++ ) {
169+ // disable the watchers on all the directives
170+ // so that the rendered content stays the same
171+ // during removal.
160172 dirs [ i ] . _watcher && dirs [ i ] . _watcher . teardown ( )
161173 }
162174}
@@ -184,20 +196,6 @@ function attach (child) {
184196 }
185197}
186198
187- /**
188- * Call destroy for all contained instances,
189- * with remove:false and defer:true.
190- * Defer is necessary because we need to
191- * keep the children to call detach hooks
192- * on them.
193- *
194- * @param {Vue } child
195- */
196-
197- function destroyChild ( child ) {
198- child . $destroy ( false , true )
199- }
200-
201199/**
202200 * Call detach hook for a Vue instance.
203201 *
0 commit comments