Fix svg/unsafe, add onBeforeUpdate, v. 0.5.6
This commit is contained in:
@@ -5,7 +5,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "nl.astraeus"
|
group = "nl.astraeus"
|
||||||
version = "0.5.5"
|
version = "0.5.7-SNAPSHOT"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<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.4" 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.6-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" 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">
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<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.4" 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.6-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" 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">
|
||||||
|
|||||||
2
komp.iml
2
komp.iml
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<module external.linked.project.id="komp" 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.version="0.5.4" type="JAVA_MODULE" version="4">
|
<module external.linked.project.id="komp" 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.version="0.5.6-SNAPSHOT" type="JAVA_MODULE" version="4">
|
||||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
<exclude-output />
|
<exclude-output />
|
||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
|
|||||||
7
komp.ipr
7
komp.ipr
@@ -97,6 +97,12 @@
|
|||||||
<element id="module-output" name="komp.jsMain" />
|
<element id="module-output" name="komp.jsMain" />
|
||||||
</root>
|
</root>
|
||||||
</artifact>
|
</artifact>
|
||||||
|
<artifact type="jar" name="komp-jslegacy-0.5.6-SNAPSHOT">
|
||||||
|
<output-path>$PROJECT_DIR$/build/libs</output-path>
|
||||||
|
<root id="archive" name="komp-jslegacy-0.5.6-SNAPSHOT.jar">
|
||||||
|
<element id="module-output" name="komp.jsMain" />
|
||||||
|
</root>
|
||||||
|
</artifact>
|
||||||
</component>
|
</component>
|
||||||
<component name="CheckStyle-IDEA">
|
<component name="CheckStyle-IDEA">
|
||||||
<option name="configuration">
|
<option name="configuration">
|
||||||
@@ -490,7 +496,6 @@
|
|||||||
<mapping directory="" vcs="Git" />
|
<mapping directory="" vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
<component name="accountSettings">
|
<component name="accountSettings">
|
||||||
<option name="activeRegion" value="us-east-1" />
|
|
||||||
<option name="recentlyUsedRegions">
|
<option name="recentlyUsedRegions">
|
||||||
<list>
|
<list>
|
||||||
<option value="us-east-1" />
|
<option value="us-east-1" />
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<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.4" 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.6-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" 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">
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<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.4" 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.6-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" 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">
|
||||||
|
|||||||
@@ -303,6 +303,7 @@ class HtmlBuilder(
|
|||||||
currentPosition.replace(currentNode!!)
|
currentPosition.replace(currentNode!!)
|
||||||
} else {
|
} else {
|
||||||
//logReplace"onTagStart, same node type")
|
//logReplace"onTagStart, same node type")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
currentElement = currentNode as? Element ?: currentElement
|
currentElement = currentNode as? Element ?: currentElement
|
||||||
@@ -319,6 +320,12 @@ class HtmlBuilder(
|
|||||||
for (entry in tag.attributesEntries) {
|
for (entry in tag.attributesEntries) {
|
||||||
currentElement!!.setKompAttribute(entry.key.lowercase(), entry.value)
|
currentElement!!.setKompAttribute(entry.key.lowercase(), entry.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tag.namespace != null) {
|
||||||
|
//logReplace"onTagStart, same node type")
|
||||||
|
|
||||||
|
(currentNode as? Element)?.innerHTML = ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//logReplace"onTagStart, currentElement2: $currentNode")
|
//logReplace"onTagStart, currentElement2: $currentNode")
|
||||||
@@ -475,7 +482,7 @@ class HtmlBuilder(
|
|||||||
(Komponent.unsafeMode == UnsafeMode.UNSAFE_SVG_ONLY && namespace == "http://www.w3.org/2000/svg")
|
(Komponent.unsafeMode == UnsafeMode.UNSAFE_SVG_ONLY && namespace == "http://www.w3.org/2000/svg")
|
||||||
) {
|
) {
|
||||||
if (currentElement?.innerHTML != textContent) {
|
if (currentElement?.innerHTML != textContent) {
|
||||||
currentElement?.innerHTML = textContent
|
currentElement?.innerHTML += textContent
|
||||||
}
|
}
|
||||||
} else if (currentElement?.textContent != textContent) {
|
} else if (currentElement?.textContent != textContent) {
|
||||||
currentElement?.textContent = textContent
|
currentElement?.textContent = textContent
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ abstract class Komponent {
|
|||||||
val declaredStyles: MutableMap<String, CSSStyleDeclaration> = HashMap()
|
val declaredStyles: MutableMap<String, CSSStyleDeclaration> = HashMap()
|
||||||
|
|
||||||
open fun create(parent: Element, childIndex: Int? = null) {
|
open fun create(parent: Element, childIndex: Int? = null) {
|
||||||
|
onBeforeUpdate()
|
||||||
val builder = HtmlBuilder(
|
val builder = HtmlBuilder(
|
||||||
parent,
|
parent,
|
||||||
childIndex ?: parent.childElementCount
|
childIndex ?: parent.childElementCount
|
||||||
@@ -65,6 +66,14 @@ abstract class Komponent {
|
|||||||
*/
|
*/
|
||||||
open fun onAfterUpdate() {}
|
open fun onAfterUpdate() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called before the Komponent is updated
|
||||||
|
* and before memoizeHash is checked
|
||||||
|
*
|
||||||
|
* note: it's also called at first render
|
||||||
|
*/
|
||||||
|
open fun onBeforeUpdate() {}
|
||||||
|
|
||||||
fun requestUpdate() {
|
fun requestUpdate() {
|
||||||
dirty = true
|
dirty = true
|
||||||
scheduleForUpdate(this)
|
scheduleForUpdate(this)
|
||||||
@@ -177,6 +186,7 @@ abstract class Komponent {
|
|||||||
val memoizeHash = next.generateMemoizeHash()
|
val memoizeHash = next.generateMemoizeHash()
|
||||||
|
|
||||||
if (memoizeHash == null || next.lastMemoizeHash != memoizeHash) {
|
if (memoizeHash == null || next.lastMemoizeHash != memoizeHash) {
|
||||||
|
next.onBeforeUpdate()
|
||||||
next.update()
|
next.update()
|
||||||
next.lastMemoizeHash = memoizeHash
|
next.lastMemoizeHash = memoizeHash
|
||||||
next.onAfterUpdate()
|
next.onAfterUpdate()
|
||||||
|
|||||||
@@ -120,6 +120,8 @@ class ReplaceKomponent : Komponent() {
|
|||||||
val includeKomponent = IncludeKomponent()
|
val includeKomponent = IncludeKomponent()
|
||||||
var includeSpan = true
|
var includeSpan = true
|
||||||
|
|
||||||
|
override fun generateMemoizeHash(): Int = includeSpan.hashCode() * 7 + includeKomponent.generateMemoizeHash()
|
||||||
|
|
||||||
override fun HtmlBuilder.render() {
|
override fun HtmlBuilder.render() {
|
||||||
div {
|
div {
|
||||||
+"Child 2"
|
+"Child 2"
|
||||||
@@ -166,6 +168,10 @@ class TestUpdate {
|
|||||||
|
|
||||||
println("ReplaceKomponent: ${div.printTree()}")
|
println("ReplaceKomponent: ${div.printTree()}")
|
||||||
|
|
||||||
|
rk.requestImmediateUpdate()
|
||||||
|
|
||||||
|
println("ReplaceKomponent: ${div.printTree()}")
|
||||||
|
|
||||||
rk.includeSpan = false
|
rk.includeSpan = false
|
||||||
rk.requestImmediateUpdate()
|
rk.requestImmediateUpdate()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user