Catch-all proposal based on proxies

Maciej Stachowiak mjs at apple.com
Thu Dec 10 18:42:16 PST 2009


On Dec 10, 2009, at 5:09 PM, Mike Samuel wrote:

> 2009/12/10 Mark S. Miller <erights at google.com>:
>
>
>>> hasOwnProperty - cannot for non host objects
>>>
>>> Incidentally, is Object.prototype.hasOwnProperty(myProxy)
>>> O(myProxyHandler.keys().length) for proxies?  This seems bad since a
>>> for (in) loop that filters out non-own properties would be O(n**2)  
>>> on
>>> top of the loop body.
>>
>> By the current taxonomy, Object.prototype.hasOwnProperty(myProxy) is
>> meta-level and always returns false on a trapping proxy, revealing  
>> that it
>> does not actually have any own properties.
>
> Hmm.  So a proxy of an object cannot be used as a drop-in replacement
> for that object with any code that uses own property loops like
>   for (var k in o) if (Object.hasOwnProperty.call(o, k)) ...
> ?
> That seems to make it less useful.
>

It would also make this mechanism unsuitable for building emulations  
of DOM objects that have catchall properties in pure ECMAScript. Is  
that a design goal for this mechanism?

Regards,
Maciej

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20091210/288d5f16/attachment-0001.html>


More information about the es-discuss mailing list