You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have experienced this issue where I have 3 levels of Vue components, calling $destroy on the top most component will not trigger the detached hook on the bottom most child.
By looking at the _destroy function, I think that the issue is that $remove is called last and at this point, on children in the hierarchy $destroy was called, causing them to remove event hooks ($off() as part of _cleanup).
I think that the removal should be brought before those cleanups, and the lifecycle order should be changed.
Evan, please excuse me if I breaking something or making faulty statement, but I couldn't anywhere when the detached hook is supposed to be called. I found one test that validates that is called after destroyed, but in my humble opinion I think that detached should be called before destroyed. After all shouldn't there be a state for a component from detached, to go back to attached, before we have destroyed the instance?
What I mean to say is that having such component hierarchy
A
-B
--C
when calling A.$destroy, the events would be
detached
-detached
--detached
beforeDestroy
-beforeDestroy
--beforeDestroy
--destroyed
-destroyed
destroyed
…d level children
Please see issue for description about the problem and what this change is supposed to fix - vuejs#1966
I know that it doesn't look good to modify tests when they fail because of a change, but I think that the lifecycle hook order should be different than what the existing test validates. The problem is again described in the issue summary
I have experienced this issue where I have 3 levels of Vue components, calling
$destroy
on the top most component will not trigger the detached hook on the bottom most child.By looking at the
_destroy
function, I think that the issue is that$remove
is called last and at this point, on children in the hierarchy$destroy
was called, causing them to remove event hooks ($off()
as part of_cleanup
).I think that the removal should be brought before those cleanups, and the lifecycle order should be changed.
Evan, please excuse me if I breaking something or making faulty statement, but I couldn't anywhere when the detached hook is supposed to be called. I found one test that validates that is called after destroyed, but in my humble opinion I think that detached should be called before destroyed. After all shouldn't there be a state for a component from detached, to go back to attached, before we have destroyed the instance?
What I mean to say is that having such component hierarchy
A
-B
--C
when calling
A.$destroy
, the events would bedetached
-detached
--detached
beforeDestroy
-beforeDestroy
--beforeDestroy
--destroyed
-destroyed
destroyed
You can observe it here http://jsfiddle.net/pepbu9cf/
I have a pending proposal for fix, will post soon.
The text was updated successfully, but these errors were encountered: