Re: [whatwg/dom] MutationObserver observed element removal (#779)

Hey annevk, that all sounds very involved. 

This differs from #533 in that I am interested specifically and only in MutationObservers ( not custom elements or general state of connectedness ) ;

My use case is with browser extensions / addons which need to know what is going on with existing 3rd party nodes on the page (without modifying them) so custom elements don't solve my problem(s). If I'm watching for changes and the node gets removed I don't know and have no way of "keeping house" (eg. when am I no longer managing the/any node(s) and in a position to respond to that).

As mentioned, doing document.contains(node) is not ideal, if even practical (depending on the page)- "things to observe" is everything - every removal has to be checked while I have any nodes of interest.

This shouldn't be difficult to implement or have any significant issues ; at the point in the code where the node is added/removed, for any observers attached to the node (in it's observers list), if there's a connected/disconnected event function on the observer call it. 

For anyone not using MutationObservers it should have little to no effect. For those who want to use it ( and there are obviously some) it'll have the least overhead for their application. 

( If there's a disconnect function on the node then it should be possible to do it with zero performance overhead where MOs not observing the node)

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/779#issuecomment-524864065

Received on Monday, 26 August 2019 13:39:08 UTC