Skip to content

Commit add1c73

Browse files
committed
destroy component after leaving transition
1 parent 224d67d commit add1c73

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/directives/component.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,21 +108,30 @@ module.exports = {
108108
*/
109109

110110
unbuild: function (remove) {
111-
if (!this.childVM) {
111+
var child = this.childVM
112+
if (!child) {
112113
return
113114
}
114115
if (this.keepAlive) {
115116
if (remove) {
116-
this.childVM.$remove()
117+
child.$remove()
117118
}
118119
} else {
119-
this.childVM.$destroy(remove)
120-
if (this.parentDirs) {
121-
var i = this.parentDirs.length
122-
while (i--) {
123-
this.parentDirs[i]._teardown()
120+
var parentDirs = this.parentDirs
121+
var destroy = function () {
122+
child.$destroy()
123+
if (parentDirs) {
124+
var i = parentDirs.length
125+
while (i--) {
126+
parentDirs[i]._teardown()
127+
}
124128
}
125129
}
130+
if (remove) {
131+
child.$remove(destroy)
132+
} else {
133+
destroy()
134+
}
126135
}
127136
this.childVM = null
128137
},

0 commit comments

Comments
 (0)