rocketraman
01/07/2022, 9:13 AM@Composable
fun ElementScope<HTMLElement>.BlockChildLink(
span: BlockChildSpan,
markDefs: List<MarkDef>,
content: @Composable ElementScope<HTMLElement>.() -> Unit
) {
val link = span.marks.linkOrNull(markDefs)
if (link != null) {
A(href = link.href) {
content()
}
} else content()
}
but this always results in empty content if the link is null i.e. the content()
to the right of the elvis operator is ignored:
@Composable
fun ElementScope<HTMLElement>.BlockChildLink(
span: BlockChildSpan,
markDefs: List<MarkDef>,
content: @Composable ElementScope<HTMLElement>.() -> Unit
) {
span.marks.linkOrNull(markDefs)?.let { link ->
A(href = link.href) {
content()
}
} ?: content()
}
ephemient
01/07/2022, 11:06 AM