mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Fix node ownership when display: contents is used (#56422)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/56422 Changelog: [GENERAL][FIXED] Fixed Yoga node ownership when `display: contents` is used in absolutely positioned subtrees Fixes an edge case where nodes with `display: contents` weren't cloned properly inside absolutely positioned subtrees. Adds a test case covering this scenario. X-link: https://github.com/facebook/yoga/pull/1924 Reviewed By: NickGerleman Differential Revision: D100581579 Pulled By: j-piasecki fbshipit-source-id: e05e9a4076bd11a71be438ef910a262044659a9b
This commit is contained in:
1 parent
b111c0efac
commit
f2f92098dd
2 files changed
+7
-1
No files matched your search
@@ -558,6 +558,7 @@ bool layoutAbsoluteDescendants(
|
||||
// we need to mutate these descendents. Make sure the path of
|
||||
// nodes to them is mutable before positioning.
|
||||
child->cloneChildrenIfNeeded();
|
||||
cleanupContentsNodesRecursively(child);
|
||||
const Direction childDirection =
|
||||
child->resolveDirection(currentNodeDirection);
|
||||
// By now all descendants of the containing block that are not absolute
|
||||
|
||||
@@ -392,7 +392,12 @@ void Node::cloneChildrenIfNeeded() {
|
||||
child = resolveRef(config_->cloneNode(child, this, i));
|
||||
child->setOwner(this);
|
||||
|
||||
if (child->hasContentsChildren()) [[unlikely]] {
|
||||
if (child->style().display() == Display::Contents) [[unlikely]] {
|
||||
// The contents node's children are treated as children of the
|
||||
// contents node's parent for layout purposes, so they need
|
||||
// to be cloned as well.
|
||||
child->cloneChildrenIfNeeded();
|
||||
} else if (child->hasContentsChildren()) [[unlikely]] {
|
||||
child->cloneContentsChildrenIfNeeded();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user