in yoga/Yoga.cpp [414:447]
static void YGNodeSetChildrenInternal(
YGNodeRef const owner,
const std::vector<YGNodeRef>& children) {
if (!owner) {
return;
}
if (children.size() == 0) {
if (YGNodeGetChildCount(owner) > 0) {
for (YGNodeRef const child : owner->getChildren()) {
child->setLayout(YGLayout());
child->setOwner(nullptr);
}
owner->setChildren(YGVector());
owner->markDirtyAndPropogate();
}
} else {
if (YGNodeGetChildCount(owner) > 0) {
for (YGNodeRef const oldChild : owner->getChildren()) {
// Our new children may have nodes in common with the old children. We
// don't reset these common nodes.
if (std::find(children.begin(), children.end(), oldChild) ==
children.end()) {
oldChild->setLayout(YGLayout());
oldChild->setOwner(nullptr);
}
}
}
owner->setChildren(children);
for (YGNodeRef child : children) {
child->setOwner(owner);
}
owner->markDirtyAndPropogate();
}
}