Support cloning of virtual ReactShadowNodes

Reviewed By: achen1

Differential Revision: D7542648

fbshipit-source-id: 58494db9f8525d4deabc6345f36941fa93a1d887
This commit is contained in:
David Vacca 2018-04-07 00:50:38 -07:00 committed by Facebook Github Bot
parent 3372541a2a
commit 16bed9e6e5
1 changed files with 14 additions and 4 deletions

View File

@ -164,22 +164,32 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
@Override
public ReactShadowNodeImpl mutableCopy() {
ReactShadowNodeImpl copy = copy();
if (mYogaNode != null) {
copy.mYogaNode = mYogaNode.clone();
copy.mYogaNode.setData(copy);
} else {
// Virtual ReactShadowNode do not have a YogaNode associated
copy.mYogaNode = null;
}
copy.mNativeChildren = mNativeChildren == null ? null : new ArrayList<>(mNativeChildren);
copy.mTotalNativeChildren = mTotalNativeChildren;
copy.mChildren = mChildren == null ? null : new ArrayList<>(mChildren);
copy.mYogaNode.setData(copy);
return copy;
}
@Override
public ReactShadowNodeImpl mutableCopyWithNewChildren() {
ReactShadowNodeImpl copy = copy();
if (mYogaNode != null) {
copy.mYogaNode = mYogaNode.cloneWithNewChildren();
copy.mYogaNode.setData(copy);
} else {
// Virtual ReactShadowNode do not have a YogaNode associated
copy.mYogaNode = null;
}
copy.mNativeChildren = null;
copy.mChildren = null;
copy.mTotalNativeChildren = 0;
copy.mYogaNode.setData(copy);
return copy;
}