Skip to content

Commit

Permalink
Mutate shared ReactShadowNode during Fabric.appendChild
Browse files Browse the repository at this point in the history
Reviewed By: shergin

Differential Revision: D7495539

fbshipit-source-id: 2b2b06d3d4f02a00b01c7ed27d47b61787ea922f
  • Loading branch information
mdvacca authored and facebook-github-bot committed Apr 6, 2018
1 parent 9736ddc commit e21bbee
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ public void appendChild(ReactShadowNode parent, ReactShadowNode child) {
Log.d(TAG, "appendChild \n\tparent: " + parent + "\n\tchild: " + child);
}
try {
// If the child to append is shared with another tree (child.getParent() != null),
// then we add a mutation of it. In the future this will be performed by FabricJS / Fiber.
//TODO: T27926878 avoid cloning shared child
if (child.getParent() != null) {
child = child.mutableCopy();
}
parent.addChildAt(child, parent.getChildCount());
} catch (Throwable t) {
handleException(parent, t);
Expand Down

0 comments on commit e21bbee

Please sign in to comment.