DOM node removal

DOM node removal

When virtual DOM nodes are removed, there is normally no need to take any action. But for example when global event listener were added during creation of the DOM Node, a cleanup action is required. To this end, the afterRemoved callback is used.

This callback is called asynchronously during an idle period (using requestIdleCallback and falling back to a setTimeout). This means it is possible that an event listener might still be called after the DOM node was actually removed from the DOM but the afterRemoved callback wasn't called yet.

The example below shows how the afterRemoved callback can be used.