We have a property that affects complex underlying state in our component. The underlying state that is affected by this property changes very rapidly (on rAF timing), and it is not worth the cost to serialize and reflect that underlying state back to the property/attribute on every frame.
So, we have configured the property with hasChanged: () => true, so that we can handle assignments to it even when the value essentially looks the same from the outside.
We received a bug report that this works as expected for property assignment, but not for setting attributes (google/model-viewer#592).
The root of the problem is that the attributeChangedCallback implementation of UpdatingElement uses a very basic, blanket dirty check that is not aware of hasChanged:
https://github.com/Polymer/lit-element/blob/508af0ee635549d1f2a87feccff4eb97b82c51ba/src/lib/updating-element.ts#L517-L521
It violates my expectations to have two different modes for dirty checking, despite explicitly configuring a check. Please consider using hasChanged in this case, or implementing an equivalent that works for attributes!
We have a property that affects complex underlying state in our component. The underlying state that is affected by this property changes very rapidly (on rAF timing), and it is not worth the cost to serialize and reflect that underlying state back to the property/attribute on every frame.
So, we have configured the property with
hasChanged: () => true, so that we can handle assignments to it even when the value essentially looks the same from the outside.We received a bug report that this works as expected for property assignment, but not for setting attributes (google/model-viewer#592).
The root of the problem is that the
attributeChangedCallbackimplementation ofUpdatingElementuses a very basic, blanket dirty check that is not aware ofhasChanged:https://github.com/Polymer/lit-element/blob/508af0ee635549d1f2a87feccff4eb97b82c51ba/src/lib/updating-element.ts#L517-L521
It violates my expectations to have two different modes for dirty checking, despite explicitly configuring a check. Please consider using
hasChangedin this case, or implementing an equivalent that works for attributes!