-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use hasChanged to check if changing attribute is dirty #699
Comments
I don't think we can reuse
|
Yes, this request still stands. We have worked around it, but ideally we would not have to do that. The number of properties that fall under the conditions described in the original issue has expanded over time. |
… method. This method allows for customizing the dirty check applied when attribute values change. The default is to avoid setting a corresponding property when an attribute changes and the old and new values are exactly the same. This is being done to address #699. It's done as an opt-in to avoid a breaking change.
@sorvell should we move this to https://github.com/lit/lit ? I don't recall if the behavior already changed in 3.0 |
This is fixed in Lit 2. |
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 ofUpdatingElement
uses 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
hasChanged
in this case, or implementing an equivalent that works for attributes!The text was updated successfully, but these errors were encountered: