Mithril.js: [rewrite] onremove is only called on top-level components

Created on 16 Jul 2016  路  2Comments  路  Source: MithrilJS/mithril.js

Description:

The onremove lifecycle hook runs on top level components, but when their descendants are also removed as a result of the parent being removed, their onremoves are never called.

Steps to Reproduce:

https://jsfiddle.net/jwa7phmq/1/

Bug

Most helpful comment

fixed in 519b352c2c05ae7e7a94f23ace60c8d47dbad540

All 2 comments

FWIW, i've gone through this issue in my own lib [1].

In the end I had to give up some removal optimizations and always do bottom-up removal in case there are deep lifecycle hooks to trigger. It gets even more hairy when those hooks can invoke async css transitions to animate out [2], delaying parent removal until resolution (i don't handle this case as it is complex and uncommon). It doesn't help that domvm also has node-level hooks, besides component-level hooks :/

Some things to consider ;)

[1] https://github.com/leeoniya/domvm
[2] https://leeoniya.github.io/domvm/demos/lifecycle-hooks.html

fixed in 519b352c2c05ae7e7a94f23ace60c8d47dbad540

Was this page helpful?
0 / 5 - 0 ratings