LinkedInAttic / LayoutKit

LayoutKit is a fast view layout library for iOS, macOS, and tvOS.
http://layoutkit.org
Apache License 2.0
3.16k stars 267 forks source link

Fix bug where a parent LK node purges child LK node's subviews #226

Open CameronAskew opened 6 years ago

CameronAskew commented 6 years ago

Description of the problem:

If you have a LayoutKit root node ("A") and somewhere in its subview hierarchy is another LayoutKit root node ("B"), and you call makeViews from A then it will traverse its entire subview hierarchy, including B's hierarchy, and remove views from B's hierarchy in ViewRecycler:purgeViews at:

for view in unidentifiedViews where view.isLayoutKitView {
    view.removeFromSuperview()
}

All other forms of layout allow for alternative layout strategies to be used freely at different places in the hierarchy without being intrusive like this. LayoutKit should resolve this internally.