fix crash when setting layoutSpec's child to nil

This commit is contained in:
rcancro 2016-05-26 15:44:21 -07:00
parent 096f20c8d5
commit cf2d9aef5c

View File

@ -117,8 +117,10 @@
ASDisplayNodeAssert(self.isMutable, @"Cannot set properties when layout spec is not mutable");
id<ASLayoutable> finalLayoutable = [self layoutableToAddFromLayoutable:child];
_children = @[finalLayoutable];
[self propagateUpLayoutable:finalLayoutable];
if (finalLayoutable) {
_children = @[finalLayoutable];
[self propagateUpLayoutable:finalLayoutable];
}
}
- (void)setChild:(id<ASLayoutable>)child forIdentifier:(NSString *)identifier
@ -127,7 +129,9 @@
id<ASLayoutable> finalLayoutable = [self layoutableToAddFromLayoutable:child];
self.childrenWithIdentifier[identifier] = finalLayoutable;
self.children = [self.children arrayByAddingObject:finalLayoutable];
if (finalLayoutable) {
self.children = [self.children arrayByAddingObject:finalLayoutable];
}
// TODO: Should we propagate up the layoutable at it could happen that multiple children will propagated up their
// layout options and one child will overwrite values from another child