Bump version to 1.2.7, add TestSvg for testing SVG rendering, and remove redundant class attribute handling in ElementExtensions.
Some checks failed
Gradle CI / build (push) Has been cancelled

This commit is contained in:
2025-05-30 12:22:21 +02:00
parent e97b6966ba
commit 177d96975a
3 changed files with 51 additions and 5 deletions

View File

@@ -11,7 +11,7 @@ plugins {
}
group = "nl.astraeus"
version = "1.2.6"
version = "1.2.7"
repositories {
mavenCentral()

View File

@@ -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)
}

View File

@@ -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()}")
}
}