File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -227,11 +227,13 @@ - (void)markDirty {
227227 // the measure function. Since we already know that this is a leaf,
228228 // this *should* be fine. Forgive me Hack Gods.
229229 const YGNodeRef node = self.node ;
230- if (!YGNodeHasMeasureFunc (node)) {
230+ if (!YGNodeHasMeasureFunc (node) && self. numberOfChildren == 0 ) {
231231 YGNodeSetMeasureFunc (node, YGMeasureView);
232232 }
233233
234- YGNodeMarkDirty (node);
234+ if (YGNodeHasMeasureFunc (node)) {
235+ YGNodeMarkDirty (node);
236+ }
235237}
236238
237239- (NSUInteger )numberOfChildren {
Original file line number Diff line number Diff line change @@ -26,5 +26,18 @@ final class FlexLayoutTests: XCTestCase {
2626
2727 XCTAssertNil ( weakView, " Creation of flex should not lead to retain cycle " )
2828 }
29+
30+
31+ func testRemoveViewDynamically( ) {
32+ let rootFlexContainer = UIView ( )
33+ rootFlexContainer. flex. addItem ( UIView ( ) )
34+ rootFlexContainer. flex. define { _ in }
35+ rootFlexContainer. flex. layout ( )
36+
37+ rootFlexContainer. subviews. forEach { $0. removeFromSuperview ( ) }
38+ rootFlexContainer. flex. markDirty ( )
39+ rootFlexContainer. flex. layout ( )
2940
41+ XCTAssertTrue ( rootFlexContainer. subviews. isEmpty)
42+ }
3043}
You can’t perform that action at this time.
0 commit comments