[Harmony Proxies] Non-extensible, sealed and frozen Proxies
David Bruant
david.bruant at labri.fr
Wed Sep 7 09:53:58 PDT 2011
Le 07/09/2011 17:39, Mark S. Miller a écrit :
>
> On Wed, Sep 7, 2011 at 7:10 AM, Tom Van Cutsem <tomvc.be at gmail.com
> <mailto:tomvc.be at gmail.com>> wrote:
>
> 2011/9/7 David Bruant <david.bruant at labri.fr
> <mailto:david.bruant at labri.fr>>
>
> Le 07/09/2011 15:38, Tom Van Cutsem a écrit :
>> [...]
>>
>>
>> I still don't see how it would work out for NodeList or other
>> host objects. Then again, I don't know whether there is a use
>> case that requires this.
> Emulating the DOM, probably. It would still be possible to
> have non-extensible trapping proxies, but not turn the proxy
> into a native DOM
> Document/Node/Element/HTMLElement/DocumentFragment, etc...
> This could create some bad performance penalty for DOM
> Traversers [1] for instance (or querySelectorAll). Would it
> even be possible to have an "hybrid" DOM tree with native DOM
> Node and emulated DOM Node?
>
>
> So a sealed/frozen DOM element requires no more interposition at all?
>
>
> I don't understand the question or how you got there.
I'm not sure I understand your question either.
I think I should refine my point.
With a proxy-emulated DOM element, would it be possible to do?
----
var myProxyEmulatedElement = Proxy.create(...);
document.body.appendChild(myProxyEmulatedElement);
----
Currently, an exception is thrown for document.body.appendChild({});
(same for a proxy).
Reading the DOM 3 spec [1], I realize that it corresponds to no
DOMException (which is normal I think), but also that this behavior
doesn't seem spec'ed.
Anyway, I think that this would be a nice feature to have. Maybe I'm
wrong. But that wasn't my initial point.
My point was that if it's not possible to turn proxies into native DOM
objects, then things that traverse DOM trees (and are expected to do so
quickly, otherwise the author had rather writing the traversal herself)
could suffer from performance penalty.
> Certainly, for security purposes, sealed/frozen DOM nodes still carry
> tremendous authority, and so we still need to interpose proxy-wrappers
> for them.
Good point.
>
> Also, how straightforward would it be to brain-transplant a Proxy
> with, say, a NodeList, as opposed to brain-transplanting a Proxy
> with a regular Object?
>
Maybe it's not straightforward. Maybe it's so difficult and annoying
that implementors are going to veto it by never doing it. Maybe that
it's impossible actually. But the question is worth asking.
David
[1] http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-184E7107
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110907/ceda5160/attachment.html>
More information about the es-discuss
mailing list