[Webkit-unassigned] [Bug 137651] WeakMap reference w/ DOM element as key does not survive long enough

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Oct 15 12:13:39 PDT 2014


https://bugs.webkit.org/show_bug.cgi?id=137651





--- Comment #6 from Geoffrey Garen <ggaren at apple.com>  2014-10-15 12:13:33 PST ---
> I think that adding a custom property on each node in WeakMap may be a reasonable workaround. Geoff, does this have any serious downsides?
> 
>   while (i--) {
>     document.body.appendChild(document.createElement('p'));
>     document.body.lastElementChild.textContent = i;
>     document.body.lastElementChild.webkitWeakMapWorkaround = 1;  // <-- This
>     wmap.set(document.body.lastElementChild, { foo: 'bar', id: i });
>   }

I think that's a reasonable workaround.

> Perhaps we can use a similar mechanism to make WeakMap work with nodes. Possibly a side HashCountedSet, or even a counter in node rare data.

I think we could. Ultimately, though, it might just be time to retire the "unobservable wrapper" optimization. Now that WeakMap and WeakSet expose GC semantics, everything is logically observable.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list