On Wed, Apr 16, 2014 at 12:37 AM, Mark S. Miller <erights@google.com> wrote:
> Summing up, using an object as a key, in either a Map or a WeakMap, should
> only depend on the same object identity as used by ===. There's no reason
> to make an exception for WindowProxy, so don't.
>
These classes let you ask questions about identity that previously there
was no way of asking. Specifically, they let you ask whether a given
object has the same identity as another object at another time. The ===
operator only lets you ask identity questions of two objects at the same
time.
Saying "just use the existing notion of identity" doesn't help resolve the
question.
Adam
> On Wed, Apr 16, 2014 at 3:16 AM, Toon Verwaest <verwaest@chromium.org>wrote:
>
>>
>> >> From a use cases perspective, there is one issue: how does one attach
>> state to a "web page"?
>> >
>> >
>> > That's a slippery notion because sometimes |w| acts like the container
>> and sometimes it acts like the thing contained. Sounds like a recipe for
>> security vulnerabilities when the author and WeakMap disagree about whether
>> they're talking about the container or the thing contained...
>>
>> If you want to associate state with a proxy, use a WeakMap.
>>
>> If you want to attach state to a specific window with all security
>> checks, install a private symbol on the window itself. (Granted, this does
>> not exist yet :-)).
>>
>
>
>
> --
> Cheers,
> --MarkM
>