The default bug view has changed. See this FAQ.

Remove MutationReceiver from MutationObserver when the target is deleted

RESOLVED FIXED

Status

()

Core
DOM
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: smaug, Assigned: smaug)

Tracking

12 Branch
x86_64
Linux
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

Created attachment 612183 [details] [diff] [review]
patch

Currently if target is deleted, MutationObserver ends up having receivers
with null target. Nothing scary there, but no need to keep such things
alive.

This patch fixes also transient receiver disconnecting.
s/Disconnect/DisconnectTransientReceiver/

The patch adds also some warnings and assertions.
Attachment #612183 - Flags: review?(jonas)
Comment on attachment 612183 [details] [diff] [review]
patch

If I understand correctly NodeWillBeDestroyed can only be called on non-transient receivers, since transient receivers are always attached to nodes which we hold a strong reference to in a MutationRecord.

Is this correct?

If so, could you add an assertion to NodeWillBeDestroyed that checks that the receiver doesn't have a parent? Mostly as documentation, but also to make sure that we don't have any bad bugs.
Attachment #612183 - Flags: review?(jonas) → review+
(In reply to Jonas Sicking (:sicking) from comment #1)
> Comment on attachment 612183 [details] [diff] [review]
> patch
> 
> If I understand correctly NodeWillBeDestroyed can only be called on
> non-transient receivers, since transient receivers are always attached to
> nodes which we hold a strong reference to in a MutationRecord.
> 
> Is this correct?
No, but nsMutationObserver has node->transientobserverlist hashtable.
That keeps node and transientobservers alive.


> 
> If so, could you add an assertion to NodeWillBeDestroyed that checks that
> the receiver doesn't have a parent? Mostly as documentation, but also to
> make sure that we don't have any bad bugs.
Sure.
Created attachment 612252 [details] [diff] [review]
+assertion
https://hg.mozilla.org/mozilla-central/rev/320065be1731
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Makes sense.
You need to log in before you can comment on or make changes to this bug.