@@ -64,12 +64,12 @@ export default function Fragment (linker, vm, frag, host, scope, parentFrag) {
64
64
65
65
Fragment . prototype . callHook = function ( hook ) {
66
66
var i , l
67
- for ( i = 0 , l = this . children . length ; i < l ; i ++ ) {
68
- hook ( this . children [ i ] )
69
- }
70
67
for ( i = 0 , l = this . childFrags . length ; i < l ; i ++ ) {
71
68
this . childFrags [ i ] . callHook ( hook )
72
69
}
70
+ for ( i = 0 , l = this . children . length ; i < l ; i ++ ) {
71
+ hook ( this . children [ i ] )
72
+ }
73
73
}
74
74
75
75
/**
@@ -147,16 +147,28 @@ function multiRemove () {
147
147
148
148
/**
149
149
* 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.
153
150
*/
154
151
155
152
Fragment . 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
+ }
157
167
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.
160
172
dirs [ i ] . _watcher && dirs [ i ] . _watcher . teardown ( )
161
173
}
162
174
}
@@ -184,20 +196,6 @@ function attach (child) {
184
196
}
185
197
}
186
198
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
-
201
199
/**
202
200
* Call detach hook for a Vue instance.
203
201
*
0 commit comments