8000 fix #276 and #281 child vms removed before parent transition finishes · terrierscript/vue@108122b · GitHub
[go: up one dir, main page]

Skip to content

Commit 108122b

Browse files
author
Evan You
committed
fix vuejs#276 and vuejs#281 child vms removed before parent transition finishes
1 parent 8f25147 commit 108122b

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

src/compiler.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ CompilerProto.resolveComponent = function (node, data, test) {
921921
/**
922922
* Unbind and remove element
923923
*/
924-
CompilerProto.destroy = function () {
924+
CompilerProto.destroy = function (noRemove) {
925925

926926
// avoid being called more than once
927927
// this is irreversible!
@@ -942,6 +942,14 @@ CompilerProto.destroy = function () {
942942
// unobserve data
943943
Observer.unobserve(compiler.data, '', compiler.observer)
944944

945+
// destroy all children
946+
// do not remove their elements since the parent
947+
// may have transitions and the children may not
948+
i = children.length
949+
while (i--) {
950+
children[i].destroy(true)
951+
}
952+
945953
// unbind all direcitves
946954
i = directives.length
947955
while (i--) {
@@ -974,23 +982,19 @@ CompilerProto.destroy = function () {
974982
}
975983
}
976984

977-
// destroy all children
978-
i = children.length
979-
while (i--) {
980-
children[i].destroy()
981-
}
982-
983985
// remove self from parent
984986
if (parent) {
985987
j = parent.children.indexOf(compiler)
986988
if (j > -1) parent.children.splice(j, 1)
987989
}
988990

989991
// finally remove dom element
990-
if (el === document.body) {
991-
el.innerHTML = ''
992-
} else {
993-
vm.$remove()
992+
if (!noRemove) {
993+
if (el === document.body) {
994+
el.innerHTML = ''
995+
} else {
996+
vm.$remove()
997+
}
994998
}
995999
el.vue_vm = null
9961000

0 commit comments

Comments
 (0)
0