Bug 16638 - Define who owns what with MutationObserver
Summary: Define who owns what with MutationObserver
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: DOM (show other bugs)
Version: unspecified
Hardware: PC Linux
: P2 normal
Target Milestone: ---
Assignee: Anne
QA Contact: public-webapps-bugzilla
Depends on:
Reported: 2012-04-05 06:33 UTC by Olli Pettay
Modified: 2012-11-09 18:59 UTC (History)
6 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Olli Pettay 2012-04-05 06:33:22 UTC
Should MutationObserver own the nodes it is observing?
I think not. If JS doesn't have a pointer to the node, it can't
modify it.
But if the original observe target is deleted, what should happen
to the transient observers? I think they should still work (until the end of
the microtask). That way GC/CC behavior isn't visible to the API user.

Then MutationObserver object itself... I think the only way to hide GC/CC
behavior is to keep MutationObserver object alive as long as
the node(s) it is observing is/are alive.
Comment 1 Ryosuke Niwa 2012-04-05 06:37:45 UTC
Yes, that makes sense.
Comment 2 Anne 2012-04-05 16:46:08 UTC
So MutationObserver has weak references to its nodes?
Comment 3 Olli Pettay 2012-04-06 08:07:54 UTC
Yes, and nodes have strong references to the MutationObservers which are
observing them
Comment 4 Anne 2012-11-09 15:10:49 UTC
Is http://dom.spec.whatwg.org/#garbage-collection correct?
Comment 6 Adam Klein 2012-11-09 15:13:19 UTC
Sounds right to me
Comment 7 Olli Pettay 2012-11-09 18:59:57 UTC
Yup, looks ok.