mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-07 17:37:34 +08:00
Support cloning of virtual ReactShadowNodes
Reviewed By: achen1 Differential Revision: D7542648 fbshipit-source-id: 58494db9f8525d4deabc6345f36941fa93a1d887
This commit is contained in:
committed by
Facebook Github Bot
parent
3372541a2a
commit
16bed9e6e5
@@ -164,22 +164,32 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
|
||||
@Override
|
||||
public ReactShadowNodeImpl mutableCopy() {
|
||||
ReactShadowNodeImpl copy = copy();
|
||||
copy.mYogaNode = mYogaNode.clone();
|
||||
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();
|
||||
copy.mYogaNode = mYogaNode.cloneWithNewChildren();
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user