Fix Komponent.create, v. 0.5.8
Took 7 minutes
This commit is contained in:
@@ -1,11 +1,10 @@
|
|||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("multiplatform") version "1.5.21"
|
kotlin("multiplatform") version "1.5.21"
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "nl.astraeus"
|
group = "nl.astraeus"
|
||||||
version = "0.5.8-SNAPSHOT"
|
version = "0.5.8"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<module external.linked.project.id="komp:commonMain" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="nl.astraeus" external.system.module.type="sourceSet" external.system.module.version="0.5.8-SNAPSHOT" type="JAVA_MODULE" version="4">
|
<module external.linked.project.id="komp:commonMain" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="nl.astraeus" external.system.module.type="sourceSet" external.system.module.version="0.5.8-SNAPSHOT" type="JAVA_MODULE" version="4">
|
||||||
<component name="FacetManager">
|
<component name="FacetManager">
|
||||||
<facet type="kotlin-language" name="Kotlin">
|
<facet type="kotlin-language" name="Kotlin">
|
||||||
<configuration version="3" platform="Common (experimental) " allPlatforms="JS []/JVM [1.8]/Native []/Native [general]" useProjectSettings="false" isTestModule="false" externalProjectId="komp" pureKotlinSourceFolders="$MODULE_DIR$/src/jsMain/kotlin;/home/rnentjes/Development/komp/komp/build/externals/komp-js-legacy/src;/home/rnentjes/Development/komp/komp/build/externals/komp-js-ir/src;/home/rnentjes/Development/komp/komp/src/jsTest/kotlin">
|
<configuration version="3" platform="Common (experimental) " allPlatforms="JS []/JVM [1.8]/Native []/Native [general]" useProjectSettings="false" isTestModule="false" externalProjectId="komp">
|
||||||
<newMppModelJpsModuleKind>SOURCE_SET_HOLDER</newMppModelJpsModuleKind>
|
<newMppModelJpsModuleKind>SOURCE_SET_HOLDER</newMppModelJpsModuleKind>
|
||||||
<compilerSettings />
|
<compilerSettings />
|
||||||
<compilerArguments>
|
<compilerArguments>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<module external.linked.project.id="komp:commonTest" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="nl.astraeus" external.system.module.type="sourceSet" external.system.module.version="0.5.8-SNAPSHOT" type="JAVA_MODULE" version="4">
|
<module external.linked.project.id="komp:commonTest" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="nl.astraeus" external.system.module.type="sourceSet" external.system.module.version="0.5.8-SNAPSHOT" type="JAVA_MODULE" version="4">
|
||||||
<component name="FacetManager">
|
<component name="FacetManager">
|
||||||
<facet type="kotlin-language" name="Kotlin">
|
<facet type="kotlin-language" name="Kotlin">
|
||||||
<configuration version="3" platform="Common (experimental) " allPlatforms="JS []/JVM [1.8]/Native []/Native [general]" useProjectSettings="false" isTestModule="true" externalProjectId="komp" pureKotlinSourceFolders="$MODULE_DIR$/src/jsMain/kotlin;/home/rnentjes/Development/komp/komp/build/externals/komp-js-legacy/src;/home/rnentjes/Development/komp/komp/build/externals/komp-js-ir/src;/home/rnentjes/Development/komp/komp/src/jsTest/kotlin">
|
<configuration version="3" platform="Common (experimental) " allPlatforms="JS []/JVM [1.8]/Native []/Native [general]" useProjectSettings="false" isTestModule="true" externalProjectId="komp">
|
||||||
<newMppModelJpsModuleKind>SOURCE_SET_HOLDER</newMppModelJpsModuleKind>
|
<newMppModelJpsModuleKind>SOURCE_SET_HOLDER</newMppModelJpsModuleKind>
|
||||||
<externalSystemTestTasks>
|
<externalSystemTestTasks>
|
||||||
<externalSystemTestTask>jsLegacyBrowserTest|komp:jsTest|jsLegacy</externalSystemTestTask>
|
<externalSystemTestTask>jsLegacyBrowserTest|komp:jsTest|jsLegacy</externalSystemTestTask>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<module external.linked.project.id="komp:jsMain" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="nl.astraeus" external.system.module.type="sourceSet" external.system.module.version="0.5.8-SNAPSHOT" type="JAVA_MODULE" version="4">
|
<module external.linked.project.id="komp:jsMain" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="nl.astraeus" external.system.module.type="sourceSet" external.system.module.version="0.5.8-SNAPSHOT" type="JAVA_MODULE" version="4">
|
||||||
<component name="FacetManager">
|
<component name="FacetManager">
|
||||||
<facet type="kotlin-language" name="Kotlin">
|
<facet type="kotlin-language" name="Kotlin">
|
||||||
<configuration version="3" platform="JavaScript " allPlatforms="JS []" useProjectSettings="false" isTestModule="false" externalProjectId="komp" pureKotlinSourceFolders="$MODULE_DIR$/src/jsMain/kotlin;/home/rnentjes/Development/komp/komp/build/externals/komp-js-legacy/src;/home/rnentjes/Development/komp/komp/build/externals/komp-js-ir/src;/home/rnentjes/Development/komp/komp/src/jsTest/kotlin">
|
<configuration version="3" platform="JavaScript " allPlatforms="JS []" useProjectSettings="false" isTestModule="false" externalProjectId="komp">
|
||||||
<dependsOnModuleNames>komp:commonMain</dependsOnModuleNames>
|
<dependsOnModuleNames>komp:commonMain</dependsOnModuleNames>
|
||||||
<sourceSets>
|
<sourceSets>
|
||||||
<sourceSet>komp.commonMain</sourceSet>
|
<sourceSet>komp.commonMain</sourceSet>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<module external.linked.project.id="komp:jsTest" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="nl.astraeus" external.system.module.type="sourceSet" external.system.module.version="0.5.8-SNAPSHOT" type="JAVA_MODULE" version="4">
|
<module external.linked.project.id="komp:jsTest" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="nl.astraeus" external.system.module.type="sourceSet" external.system.module.version="0.5.8-SNAPSHOT" type="JAVA_MODULE" version="4">
|
||||||
<component name="FacetManager">
|
<component name="FacetManager">
|
||||||
<facet type="kotlin-language" name="Kotlin">
|
<facet type="kotlin-language" name="Kotlin">
|
||||||
<configuration version="3" platform="JavaScript " allPlatforms="JS []" useProjectSettings="false" isTestModule="true" externalProjectId="komp" pureKotlinSourceFolders="$MODULE_DIR$/src/jsMain/kotlin;/home/rnentjes/Development/komp/komp/build/externals/komp-js-legacy/src;/home/rnentjes/Development/komp/komp/build/externals/komp-js-ir/src;/home/rnentjes/Development/komp/komp/src/jsTest/kotlin">
|
<configuration version="3" platform="JavaScript " allPlatforms="JS []" useProjectSettings="false" isTestModule="true" externalProjectId="komp">
|
||||||
<dependsOnModuleNames>komp:commonTest</dependsOnModuleNames>
|
<dependsOnModuleNames>komp:commonTest</dependsOnModuleNames>
|
||||||
<sourceSets>
|
<sourceSets>
|
||||||
<sourceSet>komp.commonTest</sourceSet>
|
<sourceSet>komp.commonTest</sourceSet>
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ private fun Element.getKompAttributes(): MutableSet<String> {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Element.setKompAttribute(name: String, value: String) {
|
fun Element.setKompAttribute(name: String, value: String) {
|
||||||
val setAttrs: MutableSet<String> = getKompAttributes()
|
val setAttrs: MutableSet<String> = getKompAttributes()
|
||||||
setAttrs.add(name)
|
setAttrs.add(name)
|
||||||
|
|
||||||
@@ -388,7 +388,7 @@ class HtmlBuilder(
|
|||||||
element.focus()
|
element.focus()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!setAttrs.contains(attr.name)) {
|
if (attr.name != "style" && !setAttrs.contains(attr.name)) {
|
||||||
if (element is HTMLInputElement) {
|
if (element is HTMLInputElement) {
|
||||||
if (attr.name == "checkbox") {
|
if (attr.name == "checkbox") {
|
||||||
element.checked = false
|
element.checked = false
|
||||||
@@ -515,7 +515,7 @@ class HtmlBuilder(
|
|||||||
val container = document.createElement("div") as HTMLElement
|
val container = document.createElement("div") as HTMLElement
|
||||||
val consumer = HtmlBuilder(container, 0)
|
val consumer = HtmlBuilder(container, 0)
|
||||||
content.invoke(consumer)
|
content.invoke(consumer)
|
||||||
return consumer.root ?: error("error")
|
return consumer.root ?: error("No root element found after render!")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import kotlinx.browser.window
|
|||||||
import org.w3c.dom.Element
|
import org.w3c.dom.Element
|
||||||
import org.w3c.dom.HTMLElement
|
import org.w3c.dom.HTMLElement
|
||||||
import org.w3c.dom.Node
|
import org.w3c.dom.Node
|
||||||
import org.w3c.dom.css.CSSStyleDeclaration
|
|
||||||
import org.w3c.dom.get
|
import org.w3c.dom.get
|
||||||
import kotlin.reflect.KProperty
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
@@ -40,13 +39,12 @@ abstract class Komponent {
|
|||||||
private var lastMemoizeHash: Int? = null
|
private var lastMemoizeHash: Int? = null
|
||||||
|
|
||||||
var element: Node? = null
|
var element: Node? = null
|
||||||
val declaredStyles: MutableMap<String, CSSStyleDeclaration> = HashMap()
|
|
||||||
|
|
||||||
open fun create(parent: Element, childIndex: Int? = null) {
|
open fun create(parent: Element, childIndex: Int? = null) {
|
||||||
onBeforeUpdate()
|
onBeforeUpdate()
|
||||||
val builder = HtmlBuilder(
|
val builder = HtmlBuilder(
|
||||||
parent,
|
parent,
|
||||||
childIndex ?: parent.childElementCount
|
childIndex ?: parent.childNodes.length
|
||||||
)
|
)
|
||||||
|
|
||||||
builder.render()
|
builder.render()
|
||||||
|
|||||||
Reference in New Issue
Block a user