Re: [dom] MutationObserver with querySelector for elements (#77)

I don't think we want to use CSS selectors for filtering purposes.  Evaluating selectors every time a node is added, removed, or modified is going to be unacceptably expensive.

> Then we can just require the mutation observer records be generated whenever the element is restyled, and use the restyle process to do the "element now matching" / "element no longer matching" checks.

That would expose the timing of styling recalc.  Since that's an area where different browsers optimize things differently, designing an interoperable API that doesn't degrade performance on all browsers is going to very hard.

In addition, all the use cases I've seen for filtering mutation records so far involved filtering nodes based on element names or attribute names (or combinations of the both in some rare cases).  Given that I agree with @smaug---- that DOM-based approach is better.  Also, it's not necessary for the filtering to be perfect.  If we can weed out, say, 90% of all other nodes, then scripts can quite efficiently pick the one they need after that.

---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/77#issuecomment-147326127

Received on Monday, 12 October 2015 08:18:44 UTC