Say I have an HTML hierarchy such as:
<div id="container">
<div class="c">
<div class="c"></div>
</div>
<div class="c"></div>
<div class="c"></div>
</div>
I want to monitor the DOM for this HTML to know when a new element with class c is inserted anywhere. From what I can see of MutationObserver, there is no way to do this.
Instead I have to watch #container for childList events and have it watch the whole subtree. This would be fine if my real-world code only had the above, but the DOM is huge and getting dynamic insertions/deletions all the time that are not useful or needed.
Am I missing some way of using MutationObserver to watch for insertions of an element with a specific class?