Hi, Direct proxies landed in Firefox a couple of days ago, so I thought I'd rewrite every sample I had written to the new API. I have started with the emulation of native arrays with proxies (and "normal objects") [1]. Most of my tests related to the proxyArray length fail because I only override the defineProperty trap (but not the get trap). That's fine, that's what the VirtualHandler API [2] is here for. This one is not implemented yet in Firefox [3], but I thought a bit more about how I would use it.
Line 53 [4], I use "this.delete" (this refers to the handler). Since I don't override the delete trap, this will throw an error (by definition of the VirtualHandler API as currently specified). In my case, I will have to override the delete trap with Reflect.delete (to respect ES5.1 specification of an array). Likewise for all fundamental traps. An alternative to throwing for missing trap is using the corresponding method in the Reflect module as mention in the wiki page open issue. I think it would be a good idea here. To go further with this idea, VirtualHandler.prototype, instead of inheriting from Object.prototype could inherit from Reflect. And a virtual handler instance prototype chain would then look like: instance --> VirtualHandler.prototype --> Reflect --> Object.prototype --> null VirtualHandler would just be one (convenient) way to override Reflect to generate handlers. David [1] https://github.com/DavidBruant/HarmonyProxyLab/tree/master/ProxyArray [2] http://wiki.ecmascript.org/doku.php?id=harmony:virtual_object_api [3] https://bugzilla.mozilla.org/show_bug.cgi?id=787713 [4] https://github.com/DavidBruant/HarmonyProxyLab/blob/master/ProxyArray/ProxyArray.js#L53 _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

