RE: Exposing constructors of readonly interfaces to web authors

From: Rik Cabanier [mailto:cabanier@gmail.com] 

> Can't we change the code so it always returns the same getters? ie instead of creating a new {} and getter function, keep a reference of them in the object and use them in Object.defineProperty. That way the object's prototype will always have the same getters and it won't be very costly to implement.

You cannot. (Try it! Please, try everything you are suggesting in an actual browser!) In your example, the getters close over the variables in the DOMQuad() closure (which is no longer a constructor, BTW, and thus should be lowercased: domQuad()). You need separate getters for each instance of the closure, since each instance of the closure creates a new rect variable.

Received on Saturday, 28 June 2014 19:32:39 UTC