kotlinx.html
kotlinx.html copied to clipboard
IllegalStateException: "Wrong current tag" on try to change `classes` when class inherits HTMLTag and CommonAttributeGroupFacadeFlowInteractivePhrasingContent
Initial report - https://discuss.kotlinlang.org/t/custom-components/17731/5 Code:
import kotlinx.html.*
import kotlinx.html.dom.append
import kotlin.browser.document
@ExperimentalStdlibApi
fun main() {
document.body!!.append {
p {
testButton()
}
}
}
@HtmlTagMarker
@ExperimentalStdlibApi
fun FlowOrInteractiveOrPhrasingContent.testButton() {
TestButton(
consumer
)/*.test()*/
}
class TestButton(consumer: TagConsumer<*>) :
BUTTON(
attributesMapOf(),
consumer
), Tag {
init {
console.log(classes)
classes += setOf("class")
console.log("DONE")
}
// fun test() {
// classes += setOf("class")
// }
}
Leads to the IllegalStateException
on runtime:
Dependencies:
dependencies {
implementation(kotlin("stdlib-js"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.5")
implementation("org.jetbrains:kotlin-react:16.13.0-pre.94-kotlin-1.3.70")
implementation("org.jetbrains:kotlin-react-dom:16.13.0-pre.94-kotlin-1.3.70")
}
Project in the attachment. halos-console.zip