YGNodeFree: mark parent dirty when child is freed

Summary:
fixes https://github.com/facebook/yoga/issues/1659.

**problem:** `YGNodeFree` called `owner->removeChild(node)` to detach the node from its
parent, but never called `owner->markDirtyAndPropagate()`. the parent's layout stayed
stale after the free, so a subsequent `YGNodeCalculateLayout` wouldn't recompute it.
`YGNodeRemoveChild` has always called `markDirtyAndPropagate` — `YGNodeFree` was just
missing the same call.

`YGNodeFreeRecursive` was already correct for its recursive child removals (it calls
`YGNodeRemoveChild` internally), but the terminal `YGNodeFree(root)` inherited the bug.

**fix:** added `owner->markDirtyAndPropagate()` after `node->setOwner(nullptr)` in
`YGNodeFree`.

regression tests: `dirty_parent_when_child_freed` and `dirty_parent_when_subtree_freed_recursive`
in `YGDirtyMarkingTest.cpp`.

bypass-github-export-checks

## Changelog
[General][Changed] - mark parent dirty when child is freed

X-link: https://github.com/facebook/yoga/pull/1969

Reviewed By: javache

Differential Revision: D107895988

Pulled By: cipolleschi

fbshipit-source-id: 5dce726e13147e8b7735bf72c441e80bb0c9b5a3
This commit is contained in:
harsha-cpp authored and meta-codesync[bot] committed 2026-06-09 05:07:45 -07:00
1 parent b41fffd3fc
commit 4adca58f4c
1 file changed
+1
@@ -44,6 +44,7 @@ void YGNodeFree(const YGNodeRef nodeRef) {
if (auto owner = node->getOwner()) {
owner->removeChild(node);
node->setOwner(nullptr);
owner->markDirtyAndPropagate();
}
const size_t childCount = node->getChildCount();