Catch-all proposal based on proxies
mjs at apple.com
Thu Dec 10 21:05:22 PST 2009
On Dec 10, 2009, at 8:30 PM, Mark S. Miller wrote:
> On Thu, Dec 10, 2009 at 6:42 PM, Maciej Stachowiak <mjs at apple.com>
> On Dec 10, 2009, at 5:09 PM, Mike Samuel wrote:
>> 2009/12/10 Mark S. Miller <erights at google.com>:
>>> 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?
> Hi Maciej, I agree that it is a problem. Tom & I are currently
> discussing what to do about it. But I don't understand your
> description above. What does "DOM objects that have catchall
> properties in pure ECMAScript" mean? Thanks.
It looks like I plied too many clauses and prepositional phrases into
once sentence. Let me try to rephrase:
If you want to emulate a DOM object that has catchall properties, then
it needs to return true for hasOwnProperty() for the things that
should be own properties. If you want to build that emulation in pure
ECMAScript (perhaps as a security façade), then you need a catchall
mechanism that lets the object appear to have own properties as seen
through hasOwnProperty. It seems like the proposed mechanism as
described does not allow this - assuming I understood your initial
comment quoted above correctly.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss