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

Loading…
Cancel
Save