- From: Andrea Giammarchi <notifications@github.com>
- Date: Tue, 20 Oct 2020 13:22:16 -0700
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/issues/905@github.com>
## Background The `MutationObserverInit` has a `subtree` option that is *not* usable, unless `childList` or `attributes` are also defined. The controversial part of this choice is that `attributes` inevitably involve *Element* only, while `childList` includes *Node* of any type. As result, it is impossible to optimally observe `children` that are being added, when text, comments, or character data, are being manipulated, in a way or another, by libraries and whatsoever. The workaround to fulfill an "*observe children only*" is to append any *Element* in the DOM and then `element.setAttribute('data-what', '')` so that a *MutationObserver* aware of `subtree` and `attributes` only, can verify the attribute is `data-what` and conside that node, instead of parsing every single kind of node that could land on a document/element. ## Proposal Add a `children` *boolean* property to the `MutationObserverInit` to indicate that nothing else should bother the callback in charge of screening nodes, otherwise inevitably bloated, and slowed down, by checks such as `if (addedNode.nodeType === 1) ...` or similar. Thanks for considering this improvement to one of the most successful DOM APIs in latter years. -- 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/905
Received on Tuesday, 20 October 2020 20:22:28 UTC