superfine: Missing `ondestroy` event for deep removals

It appears the onremove event isn’t triggered for children, when the parent is removed - I believe the following test demonstrates the problem:

https://github.com/mindplay-dk/picodom/commit/f108584890bdc936b44e8db5c071384bae3f3476

Looks like a bug? I’m unsure how to address it.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 30 (28 by maintainers)

Most upvoted comments

It’s good to have these discussions - terminology is super important; I find until you can put words on things, it’s likely you don’t yet understand (or don’t agree) on the division of responsibilities to different units. I think by now we’re both much clearer on what’s what 😄

Ah, the OO argument works for me, as that is exactly how you’d use ondestroy, as a destructor. 👍

When I integrated codemirror with hyperapp, I used keys to make sure onremove was called for the element I used to save codemirror’s instance.

But I think you have a point that I may have been missing something so, we should probably add a new ondestroy event that works similarly to snabbdom.

@JorgeBucaran sure, no I don’t mean it’s wierd or buggy. I just mean I think it’s somewhat uncommon to use it in the first place, that’s all. The only use case I can think of, off hand is transitions. And in that case, if the parent goes away, it’s not a problem that onremove is never called for the child.

I guess it’s probably also useful for removing event listeners if some where bound in oncreate. But in that case, it should still be quite easy to handle if the parent goes away, with an onremove handler in the parent.

Now if that were common it would be an argument to move that complexity out of userland into picodom. But I don’t know…