@@ -72,17 +72,6 @@ Fragment.prototype.callHook = function (hook) {
72
72
}
73
73
}
74
74
75
- /**
76
- * Destroy the fragment.
77
- */
78
-
79
- Fragment . prototype . destroy = function ( ) {
80
- if ( this . parentFrag ) {
81
- this . parentFrag . childFrags . $remove ( this )
82
- }
83
- this . unlink ( )
84
- }
85
-
86
75
/**
87
76
* Insert fragment before target, single node version
88
77
*
@@ -109,7 +98,7 @@ function singleRemove () {
109
98
this . inserted = false
110
99
var shouldCallRemove = inDoc ( this . node )
111
100
var self = this
112
- self . callHook ( destroyChild )
101
+ this . beforeRemove ( )
113
102
removeWithTransition ( this . node , this . vm , function ( ) {
114
103
if ( shouldCallRemove ) {
115
104
self . callHook ( detach )
@@ -147,7 +136,7 @@ function multiRemove () {
147
136
this . inserted = false
148
137
var self = this
149
138
var shouldCallRemove = inDoc ( this . node )
150
- self . callHook ( destroyChild )
139
+ this . beforeRemove ( )
151
140
removeNodeRange ( this . node , this . end , this . vm , this . frag , function ( ) {
152
141
if ( shouldCallRemove ) {
153
142
self . callHook ( detach )
@@ -156,6 +145,33 @@ function multiRemove () {
156
145
} )
157
146
}
158
147
148
+ /**
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
+ */
154
+
155
+ Fragment . prototype . beforeRemove = function ( ) {
156
+ this . callHook ( destroyChild )
157
+ var dirs = this . unlink . dirs
158
+ var i = dirs . length
159
+ while ( i -- ) {
160
+ dirs [ i ] . _watcher && dirs [ i ] . _watcher . teardown ( )
161
+ }
162
+ }
163
+
164
+ /**
165
+ * Destroy the fragment.
166
+ */
167
+
168
+ Fragment . prototype . destroy = function ( ) {
169
+ if ( this . parentFrag ) {
170
+ this . parentFrag . childFrags . $remove ( this )
171
+ }
172
+ this . unlink ( )
173
+ }
174
+
159
175
/**
160
176
* Call attach hook for a Vue instance.
161
177
*
0 commit comments