ionic-team / ionic-v1

The repo for Ionic 1.x. For the latest version of Ionic, please see https://github.com/ionic-team/ionic
Other
193 stars 187 forks source link

[BUG] collection-repeat: broken "afterNodes" concatenation (+ fix) #264

Open VinceOPS opened 7 years ago

VinceOPS commented 7 years ago

Hi.

"afterNodes" concatenation is broken when the collection-repeat is not a direct child of a scrollable content. The doc doesn't say anything about the obligation to put collection-reader at a certain level of the DOM/scrollable content. In the case of a view containing multiple sub-views (and switching between them programmatically), we can assume that the collection-repeat could be isolated into a non-specific container. That's why we should probably use the containerNode.parentNode.childNodes to see which elements are after the repeater, rather than using scrollView.__content.childNodes.

https://github.com/VinceOPS/ionic/commit/c4eb41c0d2a87d87522b7500ecd6f802fb504e0d

Otherwise, some HTML elements could be moved to collection-repeat-after-container, whereas this is not desired/expected.

I assume this thread on the forum relates to this issue/bug: https://forum.ionicframework.com/t/collection-repeat-with-infinite-scroll-in-an-ion-slide/21292/5

I can create a proper PR if asked by the team, but I'm not actually sure that the project is still maintained, so I just thought about sharing it here with everyone looking for a solution.

NB: not sure whether we should replace scrollView.__content.appendChild(container[0]); by containerNode.parentNode.appendChild(container[0]), but I assume we do.

Regards