From 649c7348ca46b613ad9751f06def507a29ed8951 Mon Sep 17 00:00:00 2001 From: heoblitz Date: Wed, 15 Oct 2025 22:53:35 +0900 Subject: [PATCH 1/3] Add validation for markDirty and SetMeasureFunc --- Sources/YogaKit/YGLayout.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/YogaKit/YGLayout.mm b/Sources/YogaKit/YGLayout.mm index c849ced..1ecda41 100644 --- a/Sources/YogaKit/YGLayout.mm +++ b/Sources/YogaKit/YGLayout.mm @@ -227,7 +227,7 @@ - (void)markDirty { // the measure function. Since we already know that this is a leaf, // this *should* be fine. Forgive me Hack Gods. const YGNodeRef node = self.node; - if (!YGNodeHasMeasureFunc(node)) { + if (!YGNodeHasMeasureFunc(node) && self.numberOfChildren == 0) { YGNodeSetMeasureFunc(node, YGMeasureView); } From 4dd70048a26043d6b0906a8d63ed674060ee6572 Mon Sep 17 00:00:00 2001 From: heoblitz Date: Wed, 15 Oct 2025 23:57:23 +0900 Subject: [PATCH 2/3] Add RemoveViewDynamically Test --- Tests/FlexLayoutTests/FlexLayoutTests.swift | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Tests/FlexLayoutTests/FlexLayoutTests.swift b/Tests/FlexLayoutTests/FlexLayoutTests.swift index bb215a7..555ec27 100644 --- a/Tests/FlexLayoutTests/FlexLayoutTests.swift +++ b/Tests/FlexLayoutTests/FlexLayoutTests.swift @@ -26,5 +26,18 @@ final class FlexLayoutTests: XCTestCase { XCTAssertNil(weakView, "Creation of flex should not lead to retain cycle") } + + + func testRemoveViewDynamically() { + let rootFlexContainer = UIView() + rootFlexContainer.flex.addItem(UIView()) + rootFlexContainer.flex.define { _ in } + rootFlexContainer.flex.layout() + + rootFlexContainer.subviews.forEach { $0.removeFromSuperview() } + rootFlexContainer.flex.markDirty() + rootFlexContainer.flex.layout() + XCTAssertTrue(rootFlexContainer.subviews.isEmpty) + } } From f14ddeedf568576cf6d6089538f2f9959bae5f09 Mon Sep 17 00:00:00 2001 From: heoblitz Date: Thu, 16 Oct 2025 10:20:53 +0900 Subject: [PATCH 3/3] Add validation for markDirty node --- Sources/YogaKit/YGLayout.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/YogaKit/YGLayout.mm b/Sources/YogaKit/YGLayout.mm index 1ecda41..311b2d6 100644 --- a/Sources/YogaKit/YGLayout.mm +++ b/Sources/YogaKit/YGLayout.mm @@ -231,7 +231,9 @@ - (void)markDirty { YGNodeSetMeasureFunc(node, YGMeasureView); } - YGNodeMarkDirty(node); + if (YGNodeHasMeasureFunc(node)) { + YGNodeMarkDirty(node); + } } - (NSUInteger)numberOfChildren {