diff --git a/Source/ASTextNode2.mm b/Source/ASTextNode2.mm index b49cde7a..c62c0bef 100644 --- a/Source/ASTextNode2.mm +++ b/Source/ASTextNode2.mm @@ -292,7 +292,10 @@ static NSArray *DefaultLinkAttributeNames() { for (NSString *linkAttributeName in _linkAttributeNames) { __block BOOL hasLink = NO; [attributedText enumerateAttribute:linkAttributeName inRange:range options:NSAttributedStringEnumerationLongestEffectiveRangeNotRequired usingBlock:^(id _Nullable value, NSRange range, BOOL * _Nonnull stop) { - hasLink = (value != nil); + if (value == nil) { + return; + } + hasLink = YES; *stop = YES; }]; if (hasLink) { diff --git a/Tests/ASTextNode2Tests.mm b/Tests/ASTextNode2Tests.mm index 39d3b7aa..9f2b8947 100644 --- a/Tests/ASTextNode2Tests.mm +++ b/Tests/ASTextNode2Tests.mm @@ -107,4 +107,18 @@ XCTAssertFalse(accessibleTextNode.isAccessibilityElement); } +- (void)testSupportsLayerBacking +{ + ASTextNode2 *textNode = [[ASTextNode2 alloc] init]; + textNode.attributedText = [[NSAttributedString alloc] initWithString:@"new string"]; + XCTAssertTrue(textNode.supportsLayerBacking); + + NSString *link = @"https://texturegroup.com"; + NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"Texture Website: %@", link]]; + NSRange linkRange = [attributedText.string rangeOfString:link]; + [attributedText addAttribute:NSLinkAttributeName value:link range:linkRange]; + textNode.attributedText = attributedText; + XCTAssertFalse(textNode.supportsLayerBacking); +} + @end