diff --git a/AsyncDisplayKit/Layout/ASLayoutSpec.mm b/AsyncDisplayKit/Layout/ASLayoutSpec.mm index b656a95782..a14a4e1e32 100644 --- a/AsyncDisplayKit/Layout/ASLayoutSpec.mm +++ b/AsyncDisplayKit/Layout/ASLayoutSpec.mm @@ -117,8 +117,10 @@ ASDisplayNodeAssert(self.isMutable, @"Cannot set properties when layout spec is not mutable"); id finalLayoutable = [self layoutableToAddFromLayoutable:child]; - _children = @[finalLayoutable]; - [self propagateUpLayoutable:finalLayoutable]; + if (finalLayoutable) { + _children = @[finalLayoutable]; + [self propagateUpLayoutable:finalLayoutable]; + } } - (void)setChild:(id)child forIdentifier:(NSString *)identifier @@ -127,7 +129,9 @@ id 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