Proxies and preventExtensions: how to avoid inconsistency in a membrane?

Isiah Meadows isiahmeadows at gmail.com
Mon Sep 5 21:28:03 UTC 2016


Is a proxy a valid proxy target? If that's the case, then the indirection
should allow you to do what you're doing. The outer proxy could freeze and
let the inner proxy know it shouldn't extend anything anymore, without
actually freezing it. The inner proxy can handle the rest of the actual
logic in the membrane.

On Sun, Sep 4, 2016, 17:06 Oriol Bugzilla <oriol-bugzilla at hotmail.com>
wrote:

> > Could there be a Proxy.hasBeenRevoked(proxy) method?
>
> The Proxy constructor only accepts targets and handlers when they are
> objects and are not revoked proxies.
>
> I wonder what's the point of not allowing revoked proxies but allow
> revocable proxies which may be revoked later.
>
>
> Anyways, this allows you to check if a value is a revoked proxy: you only
> need to ensure that it's an object but makes Proxy throw.
>
> I think something like this should work:
>
>
> ```javascript
>
> Proxy.hasBeenRevoked = function(value) {
>
>   if(Object(value) !== value) {
>
>     return false; // Primitive value
>
>   }
>
>   try {
>
>     new Proxy(value, value);
>
>     return false; // Either non-proxy object or non-revoked proxy
>
>   } catch(err) {
>
>     return true; // Revoked proxy
>
>   }
>
> };
>
> ```
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160905/35c4c369/attachment.html>


More information about the es-discuss mailing list