Open Bug 1624029 Opened 5 years ago Updated 2 years ago

Add an option to nsMutationObserver to avoid notifying about nodes not in a subtree

Categories

(Core :: DOM: Core & HTML, enhancement)

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.

See Also: → 1617669

Why not just checking SubtreeRoot(), or such in the mutation observer? seems it'd be pretty cheap.

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?

Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.