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
Binding to an array by index causes dirty checking #289
Comments
To my knowledge, this was always the behavior. @jdanyow can confirm. It may have worked without dirty checking in Chrome only, back when Array.observe was a spec. Now that it is no longer being standardized, it has been removed. Fundamentally, without Array.observe, there is no way to detect changes in indexed items of arrays without dirty checking. @jdanyow may have some recommendations on alternatives though. |
I spoke with @jdanyow in a private gitter and he asked me to log this issue. I only use Chrome at this stage so you might be right that it only worked with Chrome. This is not an important feature for us. We rewrote our code in a way that does not bind to an array by index. |
@jdanyow I think, minimally, the new databinding docs should probably call out the things that will cause dirty checking and maybe even provide various workarounds for that, if possible. |
Early on AccessKeyed didn't observe Now it does: https://github.com/aurelia/binding/blob/master/src/ast.js#L320 I think we may need to add some additional logic to that ^^^ if-statement to skip observing that part of the expression if Thoughts? |
That sounds reasonable to me :) |
For the developer whose code was depending on this functionality their code is broke now. How to achieve the same thing -
How we can achieve same behavior as before or what is the alternate way to achieve this. Meaning how to achieve displayfieldtype.$index to be observable again. Thanks |
We used to be able to bind
${myArray[0].foo}
without triggering dirty checking. This now causes dirty checking.A breakpoint in
DirtyCheckProperty.prototype.subscribe
reveals thatthis.obj
is the array andthis.propertyName
is0
. I don't know exactly when this new behavior was introduced.The text was updated successfully, but these errors were encountered: