Files
booster 706898f537 Fixed text accessibility set in extension
commit_hash:5a101d8f8ec56d83b21c01d9b1ed9a1c726708ee
2026-05-05 01:16:36 +03:00

45 lines
896 B
Swift

import DivKit
import LayoutKit
import VGSL
public final class TextExtensionHandler: DivExtensionHandler {
public let id: String
private let text: String?
public init(
id: String,
text: String?
) {
self.id = id
self.text = text
}
public func applyBeforeBaseProperties(
to block: Block,
div _: DivBase,
context _: DivBlockModelingContext
) -> Block {
guard
let textBlock = block as? TextBlock,
let text,
let newTextBlock = TextBlock(copyingAttributesFrom: textBlock, text: text)
else {
return block
}
return newTextBlock
}
public func applyAfterBaseProperties(
to block: Block,
div: DivBase,
context _: DivBlockModelingContext
) -> Block {
guard div is DivText, let text else { return block }
return block.addingDecorations(
accessibilityElement: .none(label: text)
)
}
}