Closed Bug 742371 Opened 8 years ago Closed 8 years ago

Remove MutationReceiver from MutationObserver when the target is deleted

Categories

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

12 Branch
x86_64
Linux
defect
Not set

Tracking

()

RESOLVED FIXED

People

(Reporter: smaug, Assigned: smaug)

Details

Attachments

(2 files)

Attached patch patchSplinter Review
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.
Attached patch +assertionSplinter Review
https://hg.mozilla.org/mozilla-central/rev/320065be1731
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.