Is there any way to determine if an element is being observed already?
if ( element /* is not being observed */ ) observer.observe(element)
Is there any way to determine if an element is being observed already?
if ( element /* is not being observed */ ) observer.observe(element)
Monkey patch observe()
and disconnect()
methods.
When calling observe()
collect DOM elements associated with particular observer in a WeakSet
for the observer stored in WeakMap
.
When calling disconnect()
remove the observer from the map.
To get all elements observed collect all elements from the sets in the map.
Make sure your code executes at the very beginning.