Browse Source

web: make ComposeDomNode inline (#1808)

Co-authored-by: Oleksandr Karpovich <oleksandr.karpovich@jetbrains.com>
pull/1820/head
Oleksandr Karpovich 3 years ago committed by GitHub
parent
commit
21cda3f3c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      web/core/src/jsMain/kotlin/org/jetbrains/compose/web/elements/Base.kt

16
web/core/src/jsMain/kotlin/org/jetbrains/compose/web/elements/Base.kt

@ -15,15 +15,17 @@ import org.w3c.dom.svg.SVGElement
@Composable
@ExplicitGroupsComposable
private fun <TScope, T> ComposeDomNode(
factory: () -> T,
private inline fun <TScope, T> ComposeDomNode(
crossinline factory: () -> T,
elementScope: TScope,
attrsSkippableUpdate: @Composable SkippableUpdater<T>.() -> Unit,
content: (@Composable TScope.() -> Unit)?
content: (@Composable TScope.() -> Unit)
) {
currentComposer.startNode()
if (currentComposer.inserting) {
currentComposer.createNode(factory)
currentComposer.createNode {
factory()
}
} else {
currentComposer.useNode()
}
@ -31,7 +33,7 @@ private fun <TScope, T> ComposeDomNode(
attrsSkippableUpdate.invoke(SkippableUpdater(currentComposer))
currentComposer.startReplaceableGroup(0x7ab4aae9)
content?.invoke(elementScope)
content.invoke(elementScope)
currentComposer.endReplaceableGroup()
currentComposer.endNode()
}
@ -134,7 +136,9 @@ fun <TElement : Element> TagElement(
}
},
elementScope = scope,
content = content
content = {
content?.invoke(this)
}
)
refEffect?.let { effect ->

Loading…
Cancel
Save