direct_proxies "problem"

David Bruant bruant.d at
Tue Jan 8 13:46:08 PST 2013

Le 08/01/2013 21:40, Andrea Giammarchi a écrit :
> So, I am playing with FF 18 and I have this behavior:
> var a = new Proxy([], {});
> console.log(a instanceof Array); // true
> console.log(Array.isArray(a));   // true
> console.log({};// [object Array]
> Function.apply(null, a);         // anonymous()
> Cool uh? there's no way to tell that a is not actually an array but rather a proxy: awesome!!!
> Now I go in that dark place called DOM:
> var n = new Proxy(document.createElement("p"), {});
> console.log(n instanceof HTMLElement);// true
> console.log({};     // true
really, "true" for toString?
> document.body.appendChild(n);
> // Error: Could not convert JavaScript argument arg 0 [nsIDOMHTMLBodyElement.appendChild]
> Is this meant? 'cause it looks lik ewe have half power here and once again
> inconsistencies ... thanks for explaining me this.
I don't remember when, but we had brief an exchange about it with Tom on 
es-discuss. I'm in favor for direct proxies to work as replacement of 
browser objects when they wrap it (Tom was against IIRC, but i can't 
remember the reason). It wasn't conceivable in the previous design, but 
the direct proxy design technically allow it.

Reading bugmail, following how implementations support WebIDL (bridge 
between ECMAScript and browser objects), I doubt it would be possible to 
see that happening in the short term. For this to happen would require a 
huge amount of spec work (define every single web spec algorithm in 
terms of ECMAScript object internal operations) and implementation 
obviously as Tab explained.

One idea would be in the short term that implementations reliably 
*always* throw when trying to wrap non-ECMAScript objects and play with 
them as if they were legit browser objects. If the need becomes strong, 
implementation can later allow it (turning an error into a legit thing 
is usually not web breaking)


More information about the es-discuss mailing list