@@ -35,14 +35,8 @@ - (BOOL)fb_isVisible
3535
3636@implementation FBXCElementSnapshotWrapper (FBIsVisible)
3737
38- - (BOOL )fb_hasVisibleAncestorsOrDescendants
38+ - (BOOL )fb_hasVisibleDescendants
3939{
40- if (nil != [self fb_parentMatchingOneOfTypes: @[@(XCUIElementTypeAny)]
41- filter: ^BOOL (id <FBXCElementSnapshot> _Nonnull parent) {
42- return [fetchSnapshotVisibility (parent) boolValue ];
43- }]) {
44- return YES ;
45- }
4640 for (id <FBXCElementSnapshot> descendant in (self._allDescendants ?: @[])) {
4741 if ([fetchSnapshotVisibility (descendant) boolValue ]) {
4842 return YES ;
@@ -59,9 +53,9 @@ - (BOOL)fb_isVisible
5953 }
6054
6155 // Fetching the attribute value is expensive.
62- // Shortcircuit here to save time and assume if any of descendants or ancestors
63- // are already determined as visible then the container should be visible as well
64- if ([self fb_hasVisibleAncestorsOrDescendants ]) {
56+ // Shortcircuit here to save time and assume if any of descendants
57+ // is already determined as visible then the container should be visible as well
58+ if ([self fb_hasVisibleDescendants ]) {
6559 return YES ;
6660 }
6761
@@ -72,14 +66,14 @@ - (BOOL)fb_isVisible
7266 if (nil != attributeValue) {
7367 NSMutableDictionary *updatedValue = [NSMutableDictionary dictionaryWithDictionary: self .additionalAttributes ?: @{}];
7468 [updatedValue setObject: attributeValue forKey: FB_XCAXAIsVisibleAttribute];
75- self.additionalAttributes = updatedValue.copy ;
69+ self.snapshot . additionalAttributes = updatedValue.copy ;
7670 return [attributeValue boolValue ];
7771 }
7872
7973 // If we fail to fetch the "true" visibility from AX then fallback to
8074 // the lousy `visibleFrame`-based detection method
8175 BOOL fallbackResult = !CGRectIsEmpty (self.fb_visibleFrame );
82- NSLog (@" Cannot determine '%@ ' visibility natively: %@ . Defaulting to: %@ " ,
76+ NSLog (@" Cannot determine visibility of '%@ ' natively: %@ . Defaulting to: %@ " ,
8377 self.fb_description , error.description , @(fallbackResult));
8478 return fallbackResult;
8579}
0 commit comments