From 177d96975a5bdaf228538a688203ff96e2177429 Mon Sep 17 00:00:00 2001 From: rnentjes Date: Fri, 30 May 2025 12:22:21 +0200 Subject: [PATCH] Bump version to 1.2.7, add `TestSvg` for testing SVG rendering, and remove redundant class attribute handling in `ElementExtensions`. --- build.gradle.kts | 2 +- .../nl/astraeus/komp/ElementExtentions.kt | 4 -- src/jsTest/kotlin/nl/astraeus/komp/TestSvg.kt | 50 +++++++++++++++++++ 3 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 src/jsTest/kotlin/nl/astraeus/komp/TestSvg.kt diff --git a/build.gradle.kts b/build.gradle.kts index 31aecac..4dd765a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,7 +11,7 @@ plugins { } group = "nl.astraeus" -version = "1.2.6" +version = "1.2.7" repositories { mavenCentral() diff --git a/src/jsMain/kotlin/nl/astraeus/komp/ElementExtentions.kt b/src/jsMain/kotlin/nl/astraeus/komp/ElementExtentions.kt index afd5a5d..79dd569 100644 --- a/src/jsMain/kotlin/nl/astraeus/komp/ElementExtentions.kt +++ b/src/jsMain/kotlin/nl/astraeus/komp/ElementExtentions.kt @@ -84,8 +84,6 @@ internal fun Element.setKompAttribute(attributeName: String, value: String?) { removeAttribute(attributeName) } } - } else if (attributeName == "class") { - className = "" } else { removeAttribute(attributeName) } @@ -105,8 +103,6 @@ internal fun Element.setKompAttribute(attributeName: String, value: String?) { setAttribute(attributeName, value) } } - } else if (attributeName == "class") { - className = value } else if (this.getAttribute(attributeName) != value) { setAttribute(attributeName, value) } diff --git a/src/jsTest/kotlin/nl/astraeus/komp/TestSvg.kt b/src/jsTest/kotlin/nl/astraeus/komp/TestSvg.kt new file mode 100644 index 0000000..c689038 --- /dev/null +++ b/src/jsTest/kotlin/nl/astraeus/komp/TestSvg.kt @@ -0,0 +1,50 @@ +package nl.astraeus.komp + +import kotlinx.browser.document +import kotlinx.html.InputType +import kotlinx.html.classes +import kotlinx.html.div +import kotlinx.html.i +import kotlinx.html.id +import kotlinx.html.input +import kotlinx.html.js.onClickFunction +import kotlinx.html.p +import kotlinx.html.span +import kotlinx.html.svg +import kotlinx.html.table +import kotlinx.html.td +import kotlinx.html.tr +import kotlinx.html.unsafe +import org.w3c.dom.Element +import org.w3c.dom.HTMLDivElement +import kotlin.test.Test + +class TestSvgKomponent : Komponent() { + override fun HtmlBuilder.render() { + div { + +"Test" + + svg("my-class") { + classes += "added-class" + unsafe { + +"""arc(1,2)""" + } + } + } + } +} + +class TestSvg { + + @Test + fun testUpdateWithEmpty() { + val div = document.createElement("div") as HTMLDivElement + val rk = TestSvgKomponent() + + Komponent.logRenderEvent = true + + Komponent.create(div, rk) + + println("SvgKomponent: ${div.printTree()}") + } +}