Extend ReactShadowNode in order to have a reference to the ReactShadowNode that was used to clone a node

Reviewed By: achen1

Differential Revision: D7289345

fbshipit-source-id: 34bfba8aca43299a3a8929a0e3eb85721f736dd0
This commit is contained in:
David Vacca 2018-03-19 18:21:37 -07:00 committed by Facebook Github Bot
parent b43afcdde9
commit 3f84a0a6f4
2 changed files with 19 additions and 0 deletions

View File

@ -365,4 +365,12 @@ public interface ReactShadowNode<T extends ReactShadowNode> {
* {@link ReactShadowNode}.
*/
List<ReactShadowNode> getChildrenList();
/**
* @return the {@link ReactShadowNode} that was used during the cloning mechanism to create
* this {@link ReactShadowNode} or null if this object was not created using a clone operation.
*/
@Nullable ReactShadowNode getOriginalReactShadowNode();
void setOriginalReactShadowNode(@Nullable ReactShadowNode node);
}

View File

@ -99,6 +99,7 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
private final float[] mPadding = new float[Spacing.ALL + 1];
private final boolean[] mPaddingIsPercent = new boolean[Spacing.ALL + 1];
private YogaNode mYogaNode;
private ReactShadowNode mOriginalReactShadowNode = null;
private @Nullable ReactStylesDiffMap mNewProps;
@ -1072,4 +1073,14 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
public List<ReactShadowNode> getChildrenList() {
return mChildren == null ? null : Collections.<ReactShadowNode>unmodifiableList(mChildren);
}
@Override
public ReactShadowNode getOriginalReactShadowNode() {
return mOriginalReactShadowNode;
}
@Override
public void setOriginalReactShadowNode(ReactShadowNode node) {
mOriginalReactShadowNode = node;
}
}