On Tue, Dec 18, 2012 at 4:32 PM, Alex Russell <[email protected]> wrote:
> Object.observe() is a notification, not interception, mechanism. Where we
> need to stratify an intercept, ES 6 Proxies are the mechanism we should lean
> on, but in the main, we should ALWAYS seek to avoid using them. That is to
> say, if we must do magic (use proxies), we must do magic; however we should
> only arrive there after exhausting all other routes; both on the JS and DOM
> sides.
It seems you either need to use a Proxy, some kind of wrapper method,
or a custom implementation in most cases. Typically when objects akin
to Map or Array are exposed in a platform API, mutating them has
observable (synchronous) side effects.
> Imagine we have IDL for a function:
>
> // IDL
> void takesOnlyStrings(DOMString arg, ...);
>
> // JS de-sugaring
> function takesOnlyStrings(...args) {
> if(!args.every(function(i) { return typeof i == "string"; })) {
> throw new TypeError("...");
> }
> // implementation goes here
> }
>
> But if we consider a JS-only world, the typing discussion becomes a bit less
> obvious. The semantic I'd instead expect in most libraries is for them to
> call .toString() on the argument in question, not to reject with an error.
That is what IDL specifies, fwiw.
--
http://annevankesteren.nl/
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss