diff --git a/web/core/src/jsTest/kotlin/elements/ElementsTests.kt b/web/core/src/jsTest/kotlin/elements/ElementsTests.kt index 3943f080b9..19d8b3f6a1 100644 --- a/web/core/src/jsTest/kotlin/elements/ElementsTests.kt +++ b/web/core/src/jsTest/kotlin/elements/ElementsTests.kt @@ -6,6 +6,8 @@ package org.jetbrains.compose.web.core.tests.elements import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember +import kotlinx.browser.document import org.jetbrains.compose.web.ExperimentalComposeWebApi import org.jetbrains.compose.web.attributes.AttrsBuilder import org.jetbrains.compose.web.testutils.* @@ -131,4 +133,30 @@ class ElementsTests { assertEquals("
CUSTOM
", root.outerHTML) } + + @Test + fun elementBuilderShouldBeCalledOnce() = runTest { + var counter = 0 + var flag = false + + composition { + TagElement({ + counter++ + document.createElement("div") + }, null, + if (flag) { + { Div() { Text("ON") } } + } else null + ) + + } + + assertEquals(1, counter, ) + + flag = true + waitForRecompositionComplete() + + assertEquals(1, counter) + assertEquals("
ON
", nextChild().outerHTML) + } }