direct_proxies "problem"

David Bruant bruant.d at
Sat Jan 12 13:40:02 PST 2013

Le 12/01/2013 21:58, Andrea Giammarchi a écrit :
> that is a (quick/imperfect/asexample) way to detect a proxy while I 
> understand these should not be detectable.
{} and [] also return true to your test, but they're not proxies. You 
cannot use an imperfect test to prove a point.
As I (and others now) said, the DOM, in order to be self-consistent (and 
have performance in operations like selector matching) can only use 
objects it created through HTML parsing or methods like 
document.createElement. It will refuse any other object, proxy or not. 
With tree manipulation methods (like appendChild), the only relevant 
test you can be making is "is this object a DOM created genuine node?". 
This rules out *any* object. This includes proxies to node

> Consider that as conditional check after node instanceof Element in 
> order to know if that node is usable or not as DOM element.

> There, a way to simulate an isProxy method and it does not matter if 
> that's silly ... is possible
The possibility to use proxies in the DOM tree was ruled out because of 
the selector matching use case. If you have a solution to put proxies in 
the DOM tree without ruining selector matching perf, you will be listened.


> On Sat, Jan 12, 2013 at 11:24 AM, Brendan Eich <brendan at 
> <mailto:brendan at>> wrote:
>     This is silly.
>     I can use the closure pattern to vend objects that do not satisfy
>     the internal constraints the DOM imposes on some of its objects.
>     No proxies in sight.
>     So why is the method you wrote named "isDOMProxy" and whatever in
>     the world does it have to do with Proxy?
>     /be
>     Andrea Giammarchi wrote:
>         and in both cases you would have ...
>         Proxy.isDOMProxy = function (node) {
>           try {
>             document.documentElement.appendChild(node);
>             document.documentElement.removeChild(node);
>             return false;
>           } catch(gotcha) {
>             return true;
>           }
>         };
>         that's why I have talked about inconsistencies all over at the
>         very beginning of this thread :)
>         br
>         On Sat, Jan 12, 2013 at 10:26 AM, Nathan Wall
>         <nathan.wall at <mailto:nathan.wall at>
>         <mailto:nathan.wall at <mailto:nathan.wall at>>>
>         wrote:
>             Nathan wrote:
>             >
>             > Hey Tom, I think you missed my point. The point was that in
>             David and Boris' discussion they agreed that the DOM
>         should throw
>             if it is given a Proxy in `appendChild`. That sounded to
>         me like
>             it presumed that the DOM had a magical ability to distinguish
>             between DOM objects and their proxies. That seemed to
>         contradict
>             the point David made that Proxies should not be
>         distinguishable
>             from their targets (e.g. the no `Proxy.isProxy` decision).
>         If real
>             DOM had a way to determine if something was a proxy (with
>         a target
>             of a *real* DOM node) and throw but there was no way for an
>             emulated DOM (in a non-DOM environment) to determine if an
>         object
>             was a proxy with a target to an emulated DOM node or just
>         a plain
>             emulated DOM node, then the DOM has magical abilities that the
>             emulated DOM can't have. That was my concern.
>             >
>             > David's reply works, though, I think. He stated that
>         since you
>             have to create DOM nodes using a method of the DOM itself
>             (`document.createElement`, `document.createTextNode`), then
>             emulated DOM could track all objects created and compare them
>             against objects passed into `appendChild`, and since a
>         proxy would
>             have a different object identity from its target, the
>         emulated DOM
>             would have a way to distinguish proxies from their targets.
>             >
>             > Nathan
>             In short, if real DOM can throw when given a proxy of a
>         real DOM
>             node, fake DOM should also be able to throw when given a
>         proxy of
>             a fake DOM node.
>             _______________________________________________
>             es-discuss mailing list
>         es-discuss at <mailto:es-discuss at>
>         <mailto:es-discuss at <mailto:es-discuss at>>
> _______________________________________________
> es-discuss mailing list
> es-discuss at

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list