peerlibrary / meteor-blaze-components

Reusable components for Blaze
http://components.meteorapp.com/
BSD 3-Clause "New" or "Revised" License
354 stars 26 forks source link

Do not clear componentParent on destroy #61

Open mitar opened 9 years ago

mitar commented 9 years ago

I am thinking that it is useful to not clear componentParent on destroy of a component. How it currently works is that when a component is created, componentParent and (corresponding children entry) is created. And when the component is destroyed, this it is cleared.

But this does not work well with a pattern where you are reusing components. In some cases it is better to create components in advance and then render them when needed. So same component is rendered multiple times. And components have a persistent hierarchy, and some of them gets rendered and some removed. But components are there all the time. And sometimes you then want to walk up and down the hierarchy even if the component is not rendered to still update its internal state. So that when it gets rendered again, the state is set.

So this would be slightly backwards incompatible. To get current behavior you should filter results from componentParent and componentChildren using isCreated. But I am not sure if people really depend on this behavior?

cc @Retronator

mitar commented 8 years ago

Then we can maybe check the structure after rendering on the server side in the testBlockHelpersStructure test?