framework icon indicating copy to clipboard operation
framework copied to clipboard

Templating/binding detaches incorrect nested component when splicing from a databound array

Open jussimattila opened this issue 10 years ago • 3 comments

When removing an item from an array bound to custom components with repeat.for="...", it is possible that an incorrect nested component is detached. This occurs only if the nested component is contained within another component that doesn't implement attached() or detached(). The workaround is to add one of these methods.

I ran into this issue while developing an application and managed to reproduce it here: https://gist.run/?id=e88ade5198924c5d2cf2

jussimattila avatar Mar 16 '16 06:03 jussimattila

Note that in the reproducible, when the alert is shown, values remaining in the custom component are incorrect. After the alert is dismissed, correct data is bound to the custom component. Nevertheless, when detached() is called, it is called in the wrong viewmodel, so any custom logic in that method will be applied in an incorrect context.

jussimattila avatar Mar 16 '16 06:03 jussimattila

@jdanyow @martingust I'm going to guess this has to do with some of the recent optimizations around lifecycle. Can you take a look?

EisenbergEffect avatar Mar 16 '16 10:03 EisenbergEffect

reproducible in more recent build: https://gist.run/?id=173e62d9adfc6b776814

jdanyow avatar Mar 21 '16 23:03 jdanyow