Prepending root scope ID

Summary: Using just the scope identifier for the root component is not sufficient when it doesn't have a scope. Solve this by prepending the scope root identifier to the parent identifier.

Reviewed By: fabiomassimo

Differential Revision: D19600721

fbshipit-source-id: d90f9ffd7ae369c76316cebc4ef792626a4584b7
This commit is contained in:
Andrey Mishanin
2020-01-28 08:25:26 -08:00
committed by Facebook Github Bot
parent 7964772f82
commit 67a1c27af2
3 changed files with 9 additions and 2 deletions

View File

@@ -25,5 +25,6 @@
@property (nonatomic, readonly) CKFlexboxComponentChild flexboxChild;
+ (instancetype)newFromRoot:(id<CKInspectableView>)root;
+ (instancetype)newFromRoot:(id<CKInspectableView>)root parentKey:(NSString *)parentKey;
@end

View File

@@ -44,6 +44,10 @@ static CKFlexboxComponentChild findFlexboxLayoutParams(CKComponent *parent, CKCo
@implementation SKComponentLayoutWrapper
+ (instancetype)newFromRoot:(id<CKInspectableView>)root {
return [self newFromRoot:root parentKey:@""];
}
+ (instancetype)newFromRoot:(id<CKInspectableView>)root parentKey:(NSString *)parentKey {
const CKComponentLayout layout = [root mountedLayout];
// Check if there is a cached wrapper.
if (layout.component) {
@@ -59,7 +63,7 @@ static CKFlexboxComponentChild findFlexboxLayoutParams(CKComponent *parent, CKCo
SKComponentLayoutWrapper *const wrapper =
[[SKComponentLayoutWrapper alloc] initWithLayout:layout
position:CGPointMake(0, 0)
parentKey:[NSString stringWithFormat: @"%d.", component.treeNode.nodeIdentifier]
parentKey:[NSString stringWithFormat: @"%@%d.", parentKey, component.treeNode.nodeIdentifier]
reuseWrapper:reuseWrapper
rootNode: root];
// Cache the result.

View File

@@ -32,7 +32,9 @@
}
- (id)childForNode:(CKComponentRootView *)node atIndex:(NSUInteger)index {
return [SKComponentLayoutWrapper newFromRoot:node];
auto const attachState = CKGetAttachStateForView(node);
return [SKComponentLayoutWrapper newFromRoot:node
parentKey:[NSString stringWithFormat:@"%d.", attachState.scopeIdentifier]];
}
- (void)setHighlighted:(BOOL)highlighted forNode:(CKComponentRootView *)node {