On Sat, Jun 28, 2014 at 12:32 PM, Domenic Denicola <
domenic@domenicdenicola.com> wrote:
> 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.
>
o yes. I forgot that they would become closures.
Given this, can you ever use attributes in JS object and have them return
the same getter function?
Can we ever use attributes in the DOM? Also, who relies on them being the
same? That seems like a strange assumption.