[ASIndexedNodeContext] Do not cache the envTraitCollection, use the delegate to request it when needed (#2963)

Caching the envTraitCollection upon creation of `ASIndexedNodeContext` can lead to it becoming out of date. Ask the `id<ASEnvironment>` object for the trait collection when we need it.
This commit is contained in:
ricky 2017-02-01 13:38:52 -08:00 committed by Adlai Holler
parent d7670780b2
commit 39298f6694
2 changed files with 1 additions and 3 deletions

View File

@ -25,7 +25,6 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly, copy, nullable) NSString *supplementaryElementKind;
@property (nonatomic, readonly, assign) ASSizeRange constrainedSize;
@property (weak, nonatomic) id<ASEnvironment> environment;
@property (nonatomic, readonly, assign) ASEnvironmentTraitCollection environmentTraitCollection;
- (instancetype)initWithNodeBlock:(ASCellNodeBlock)nodeBlock
indexPath:(NSIndexPath *)indexPath

View File

@ -41,7 +41,6 @@
_supplementaryElementKind = [supplementaryElementKind copy];
_constrainedSize = constrainedSize;
_environment = environment;
_environmentTraitCollection = environment.environmentTraitCollection;
}
return self;
}
@ -59,7 +58,7 @@
node.cachedIndexPath = _indexPath;
node.supplementaryElementKind = _supplementaryElementKind;
node.owningNode = (ASDisplayNode *)_environment;
ASEnvironmentStatePropagateDown(node, _environmentTraitCollection);
ASEnvironmentStatePropagateDown(node, [_environment environmentTraitCollection]);
_node = node;
}
return _node;