You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After defining multiple classes with withUpdate, every instance of all classes will have the combination of all property getters/setters from every class in the application.
Expected behaviour
Each element instance should only have the property getters/setters of the props defined by it's class, not those of any other class.
more details
The reason this happens is because there's an _observedAttributes array on the WithUpdate class. This array is shared with all class constructor instances that inherit from WithUpdate.
The problem is similar to placing an array as a prototype property, and having all instances push/pop to/from it.
The solution is to create one array per constructor that inherits from WithUpdate. We can do that by placing the following line at the top of the static get observedAttributes getter:
staticgetobservedAttributes(): Array<string>{if(!('_observedAttributes'inthis))this._observedAttributes=[]// THIS LINEdefineProps(this,WithUpdate);returnthis._observedAttributes.concat(super.observedAttributes||[]);}
It causes a new array to be created per class instance, instead of using the shared array defined by static _observedAttributes = [];.
The text was updated successfully, but these errors were encountered:
Uh oh, I just noticed that this applies with _attributeToAttributeMap and _attributeToPropertyMap too! Each new subclass will clobber other subclass definitions if they have the same attribute names.
It doesn't look like these problems exist in the latest master any more.
Bug report
Delete this section if this is a feature request.
Current behaviour
After defining multiple classes with
withUpdate
, every instance of all classes will have the combination of all property getters/setters from every class in the application.Expected behaviour
Each element instance should only have the property getters/setters of the
props
defined by it'sclass
, not those of any other class.more details
The reason this happens is because there's an
_observedAttributes
array on theWithUpdate
class. This array is shared with allclass
constructor instances that inherit fromWithUpdate
.The problem is similar to placing an array as a prototype property, and having all instances push/pop to/from it.
The solution is to create one array per constructor that inherits from
WithUpdate
. We can do that by placing the following line at the top of thestatic get observedAttributes
getter:It causes a new array to be created per class instance, instead of using the shared array defined by
static _observedAttributes = [];
.The text was updated successfully, but these errors were encountered: