diff --git a/build.gradle.kts b/build.gradle.kts index 47f7d96..f5633d2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,79 +1,78 @@ - plugins { - kotlin("multiplatform") version "1.5.21" - `maven-publish` + kotlin("multiplatform") version "1.5.21" + `maven-publish` } group = "nl.astraeus" -version = "0.5.8-SNAPSHOT" +version = "0.5.8" repositories { - mavenCentral() + mavenCentral() } kotlin { - js(BOTH) { - browser { - testTask { - useKarma { - useChromiumHeadless() - //useChromeHeadless() - } - } + js(BOTH) { + browser { + testTask { + useKarma { + useChromiumHeadless() + //useChromeHeadless() } + } } + } - sourceSets { - val commonMain by getting { - dependencies { - implementation(kotlin("stdlib-common")) + sourceSets { + val commonMain by getting { + dependencies { + implementation(kotlin("stdlib-common")) - api("org.jetbrains.kotlinx:kotlinx-html-js:0.7.3") - } - } - val jsMain by getting { - dependencies { - implementation(kotlin("stdlib-js")) - } - } - val jsTest by getting { - dependencies { - implementation(kotlin("test-js")) - } - } + api("org.jetbrains.kotlinx:kotlinx-html-js:0.7.3") + } } + val jsMain by getting { + dependencies { + implementation(kotlin("stdlib-js")) + } + } + val jsTest by getting { + dependencies { + implementation(kotlin("test-js")) + } + } + } } publishing { - repositories { - if (project.properties["nexusUsername"] != null) { - maven { - name = "releases" - url = uri("https://nexus.astraeus.nl/nexus/content/repositories/releases") - credentials { - val nexusUsername: String by project - val nexusPassword: String by project + repositories { + if (project.properties["nexusUsername"] != null) { + maven { + name = "releases" + url = uri("https://nexus.astraeus.nl/nexus/content/repositories/releases") + credentials { + val nexusUsername: String by project + val nexusPassword: String by project - username = nexusUsername - password = nexusPassword - } - } - maven { - name = "snapshots" - url = uri("https://nexus.astraeus.nl/nexus/content/repositories/snapshots") - credentials { - val nexusUsername: String by project - val nexusPassword: String by project - - username = nexusUsername - password = nexusPassword - } - } - } else { - println("Publishing disabled properties not found.") + username = nexusUsername + password = nexusPassword } + } + maven { + name = "snapshots" + url = uri("https://nexus.astraeus.nl/nexus/content/repositories/snapshots") + credentials { + val nexusUsername: String by project + val nexusPassword: String by project + + username = nexusUsername + password = nexusPassword + } + } + } else { + println("Publishing disabled properties not found.") } - publications { - val kotlinMultiplatform by getting {} - } + } + publications { + val kotlinMultiplatform by getting {} + } } diff --git a/komp.commonMain.iml b/komp.commonMain.iml index e8bc3ed..8d47892 100644 --- a/komp.commonMain.iml +++ b/komp.commonMain.iml @@ -2,7 +2,7 @@ - + SOURCE_SET_HOLDER diff --git a/komp.commonTest.iml b/komp.commonTest.iml index 5629263..d337bdc 100644 --- a/komp.commonTest.iml +++ b/komp.commonTest.iml @@ -2,7 +2,7 @@ - + SOURCE_SET_HOLDER jsLegacyBrowserTest|komp:jsTest|jsLegacy diff --git a/komp.jsMain.iml b/komp.jsMain.iml index 5812dfd..f2d8d9e 100644 --- a/komp.jsMain.iml +++ b/komp.jsMain.iml @@ -2,7 +2,7 @@ - + komp:commonMain komp.commonMain diff --git a/komp.jsTest.iml b/komp.jsTest.iml index 08181a7..8ce8734 100644 --- a/komp.jsTest.iml +++ b/komp.jsTest.iml @@ -2,7 +2,7 @@ - + komp:commonTest komp.commonTest diff --git a/src/jsMain/kotlin/nl/astraeus/komp/HtmlBuilder.kt b/src/jsMain/kotlin/nl/astraeus/komp/HtmlBuilder.kt index 4fd9cfa..af26834 100644 --- a/src/jsMain/kotlin/nl/astraeus/komp/HtmlBuilder.kt +++ b/src/jsMain/kotlin/nl/astraeus/komp/HtmlBuilder.kt @@ -112,7 +112,7 @@ private fun Element.getKompAttributes(): MutableSet { return result } -private fun Element.setKompAttribute(name: String, value: String) { +fun Element.setKompAttribute(name: String, value: String) { val setAttrs: MutableSet = getKompAttributes() setAttrs.add(name) @@ -388,7 +388,7 @@ class HtmlBuilder( element.focus() } - if (!setAttrs.contains(attr.name)) { + if (attr.name != "style" && !setAttrs.contains(attr.name)) { if (element is HTMLInputElement) { if (attr.name == "checkbox") { element.checked = false @@ -515,7 +515,7 @@ class HtmlBuilder( val container = document.createElement("div") as HTMLElement val consumer = HtmlBuilder(container, 0) content.invoke(consumer) - return consumer.root ?: error("error") + return consumer.root ?: error("No root element found after render!") } } } diff --git a/src/jsMain/kotlin/nl/astraeus/komp/Komponent.kt b/src/jsMain/kotlin/nl/astraeus/komp/Komponent.kt index 901328a..b1f8651 100644 --- a/src/jsMain/kotlin/nl/astraeus/komp/Komponent.kt +++ b/src/jsMain/kotlin/nl/astraeus/komp/Komponent.kt @@ -4,7 +4,6 @@ import kotlinx.browser.window import org.w3c.dom.Element import org.w3c.dom.HTMLElement import org.w3c.dom.Node -import org.w3c.dom.css.CSSStyleDeclaration import org.w3c.dom.get import kotlin.reflect.KProperty @@ -40,13 +39,12 @@ abstract class Komponent { private var lastMemoizeHash: Int? = null var element: Node? = null - val declaredStyles: MutableMap = HashMap() open fun create(parent: Element, childIndex: Int? = null) { onBeforeUpdate() val builder = HtmlBuilder( parent, - childIndex ?: parent.childElementCount + childIndex ?: parent.childNodes.length ) builder.render()