Add production workaround for missing elements (#3158)

This commit is contained in:
Adlai Holler
2017-03-10 06:35:20 -08:00
committed by Huy Nguyen
parent a0e67a8b15
commit bfe35fc0b1
2 changed files with 27 additions and 3 deletions

View File

@@ -1740,14 +1740,22 @@ static NSString * const kReuseIdentifier = @"_ASCollectionReuseIdentifier";
// Visible items
for (NSIndexPath *indexPath in self.indexPathsForVisibleItems) {
ASCollectionElement *element = [map elementForItemAtIndexPath:indexPath];
[result addObject:element];
if (element != nil) {
[result addObject:element];
} else {
ASDisplayNodeFailAssert(@"Couldn't find 'visible' item at index path %@ in map %@", indexPath, map);
}
}
// Visible supplementary elements
for (NSString *kind in map.supplementaryElementKinds) {
for (NSIndexPath *indexPath in [self asdk_indexPathsForVisibleSupplementaryElementsOfKind:kind]) {
ASCollectionElement *element = [map supplementaryElementOfKind:kind atIndexPath:indexPath];
[result addObject:element];
if (element != nil) {
[result addObject:element];
} else {
ASDisplayNodeFailAssert(@"Couldn't find 'visible' supplementary element of kind %@ at index path %@ in map %@", kind, indexPath, map);
}
}
}
return result;

View File

@@ -13,8 +13,9 @@
#import <AsyncDisplayKit/ASMutableElementMap.h>
#import <AsyncDisplayKit/ASSection.h>
#import <AsyncDisplayKit/NSIndexSet+ASHelpers.h>
#import <AsyncDisplayKit/ASObjectDescriptionHelpers.h>
@interface ASElementMap ()
@interface ASElementMap () <ASDescriptionProvider>
@property (nonatomic, strong, readonly) NSArray<ASSection *> *sections;
@@ -168,6 +169,21 @@
return [_elementToIndexPathMap countByEnumeratingWithState:state objects:buffer count:len];
}
#pragma mark - ASDescriptionProvider
- (NSString *)description
{
return ASObjectDescriptionMake(self, [self propertiesForDescription]);
}
- (NSMutableArray<NSDictionary *> *)propertiesForDescription
{
NSMutableArray *result = [NSMutableArray array];
[result addObject:@{ @"items" : _sectionsOfItems }];
[result addObject:@{ @"supplementaryElements" : _supplementaryElements }];
return result;
}
#pragma mark - Internal
/**