Add an option to nsMutationObserver to avoid notifying about nodes not in a subtree
Categories
(Core :: DOM: Core & HTML, enhancement)
Tracking
()
People
(Reporter: zbraniecki, Unassigned)
References
Details
Spin off from bug 1617669
It seems that at the moment, nsMutationObserver set on a document will notify about nodes that are mutated in shadowDOM.
This happens because of https://searchfox.org/mozilla-central/rev/96f1457323cc598a36f5701f8e67aedaf97acfcf/dom/base/MutationObservers.cpp#84-88
It would be useful for use cases like Fluent (which requires callers to attach the root directly so shadowRoot will have its own MutationObserver) to be able to set an option in nsMutationObserver to make it not report such mutations.
Comment 1•5 years ago
|
||
Why not just checking SubtreeRoot()
, or such in the mutation observer? seems it'd be pretty cheap.
Reporter | ||
Comment 2•5 years ago
|
||
DOMLocalization
API allows you to connect any node as a root and then all its children should be observed (except of shadowDOM).
Maybe I could check SubtreeRoot
and if it's shadowRoot then check if its one of the roots in DOMLocalization
?
Comment 3•5 years ago
|
||
FWIW, I suggested use of SubtreeRoot in bug 1617669 ;)
https://phabricator.services.mozilla.com/D67111#inline-399583
Updated•2 years ago
|
Description
•