On Sun, 23 Oct 2016 at 20:59 Toni <[email protected]> wrote:

> 1. By default, properties of Polymer objects are shared across all
> instances of the object (or, to be more precise, all references to the
> object, since Polymer doesn't create new instances, as in "new Element()").
> Basically, all properties are by default static.
>

This is not quite accurate.


> 2. Every property that is supposed to be individual to the specific
> reference, in other words, be not static, and changable without messing
> with any other instance/reference, has to have the field "value: function()
> { return []; }".
>

This is only required for Arrays and Objects.

Explanation:

In Javascript all variables are passed-by-value. The variable "holding" an
Object doesn't actually hold the Object; it only holds a reference to the
Object in memory. Whereas a variable pertaining to a primitive type
actually holds the value rather than a reference to the value in memory.

When Polymer creates a new instance of your element it copies the prototype
into a new Object. When the variable is copied the value is copied and
passed-by-value but as the value is actually a reference to the original
Object then the new instance will use the same object as all other
instances.

This is a problem with Javascript in general and not specific to Polymer.

Dan.

Follow Polymer on Google+: plus.google.com/107187849809354688692
--- 
You received this message because you are subscribed to the Google Groups 
"Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/polymer-dev/CABtuYwfLtupeCsgP-NVxoXbHEC2Yqna9%3DyfRuqCXxQRjGKVgXQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to