Paul Rouget wrote:
> Context: in the firefox devtools, we need to track some nodes and update
> different "views" based on what's happening to this node (show its parents,
> show its child, show its attributes, …).
> 
> The new Mutation observers are very helpful. But there's one thing I am not
> really sure how to handle correctly .
> 
> When a node gets detached (parent.removeChild(node)) or reparented, I need to
> be notified.
> 
> My current idea is to listen to "childList" mutations from the parent,
> then, on this mutation, check if the node is still part of the children of
> the parent, if not, check if it has a parent, if so, the node has been
> *relocated*, then I need re-listen to a "childList" mutation from this
> new parent, if no parent, the node has been *detached*.
> 
> I was wondering if there was any better way to do that.

Another way to do it is to listen to subtree mutations from the documentElement,
and then check if the targeted node is part of the removeNodes list. Would that
deteriorate the performance?

-- Paul
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to