Fabric: Fixing an incorrect empty image placeholder for NSAttributedString attachment

Summary:
Same as D18048277 but for Fabric text infra.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: PeteTheHeat

Differential Revision: D18950415

fbshipit-source-id: 09701e261ecb871b3624260a36dd607fdb70e717
This commit is contained in:
Valentin Shergin
2019-12-12 11:56:28 -08:00
committed by Facebook Github Bot
parent aaa2765a92
commit 7cf43afa8d
@@ -217,6 +217,12 @@ static NSDictionary<NSAttributedStringKey, id> *RCTNSTextAttributesFromTextAttri
NSAttributedString *RCTNSAttributedStringFromAttributedString(const AttributedString &attributedString)
{
static UIImage *placeholderImage;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
placeholderImage = [[UIImage alloc] init];
});
NSMutableAttributedString *nsAttributedString = [[NSMutableAttributedString alloc] init];
[nsAttributedString beginEditing];
@@ -230,6 +236,7 @@ NSAttributedString *RCTNSAttributedStringFromAttributedString(const AttributedSt
.size = {.width = layoutMetrics.frame.size.width, .height = layoutMetrics.frame.size.height}};
NSTextAttachment *attachment = [NSTextAttachment new];
attachment.image = placeholderImage;
attachment.bounds = bounds;
nsAttributedStringFragment = [NSAttributedString attributedStringWithAttachment:attachment];