Weak Reference proposal
jonas at sicking.cc
Wed Feb 17 06:25:26 UTC 2016
On Tue, Feb 16, 2016 at 7:50 PM, Isiah Meadows <isiahmeadows at gmail.com> wrote:
> As an example, if you observe a node with a MutationObserver, but unmount it
> and don't retain an explicit reference to it, your mutation observer will
> soon stop providing updates, since it only maintains a weak reference to the
> node by spec. It can be observed.
How is this different from the MutationObserver holding a strong
reference to the node?
The observer will still not receive any notifications since if no one
else is holding references to the node, then no one else is going to
modify it either. Hence there will be nothing to notify about.
It might certainly be possible to use a WeakRef in order to optimize
the implementation (I can't say with certainty without checking the
spec more thoroughly), but it doesn't seem required.
More information about the es-discuss