diff --git a/.idea/compiler.xml b/.idea/compiler.xml
deleted file mode 100644
index a646e3b..0000000
--- a/.idea/compiler.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
deleted file mode 100644
index 97626ba..0000000
--- a/.idea/encodings.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
deleted file mode 100644
index 3d0a41a..0000000
--- a/.idea/gradle.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_common_1_1_0.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_common_1_1_0.xml
deleted file mode 100644
index 3810470..0000000
--- a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_common_1_1_0.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_4.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_4.xml
deleted file mode 100644
index 1b8b422..0000000
--- a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_4.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_html_common_0_6_2.xml b/.idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_html_common_0_6_2.xml
deleted file mode 100644
index 835e744..0000000
--- a/.idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_html_common_0_6_2.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_html_js_0_6_2.xml b/.idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_html_js_0_6_2.xml
deleted file mode 100644
index 902474d..0000000
--- a/.idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_html_js_0_6_2.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
deleted file mode 100644
index 84da703..0000000
--- a/.idea/misc.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index 86a46a8..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules/komp.iml b/.idea/modules/komp.iml
deleted file mode 100644
index a7df91a..0000000
--- a/.idea/modules/komp.iml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules/komp_test.iml b/.idea/modules/komp_test.iml
deleted file mode 100644
index 8991e48..0000000
--- a/.idea/modules/komp_test.iml
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 94a25f7..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index c70e633..efa0f3d 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,5 +1,5 @@
group 'nl.astraeus'
-version '0.0.5-SNAPSHOT'
+version '0.0.6-SNAPSHOT'
apply plugin: 'kotlin2js'
apply plugin: 'idea'
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 4e7ab3c..24f7c83 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Sun Sep 03 11:51:07 CEST 2017
+#Sun Sep 10 13:56:55 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-all.zip
diff --git a/.idea/modules/komp_main.iml b/komp.iml
similarity index 54%
rename from .idea/modules/komp_main.iml
rename to komp.iml
index 91f55dd..a88fd57 100644
--- a/.idea/modules/komp_main.iml
+++ b/komp.iml
@@ -1,13 +1,13 @@
-
+
-
+
-
+
@@ -23,18 +23,24 @@
-
-
-
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
diff --git a/komp.ipr b/komp.ipr
new file mode 100644
index 0000000..f46dbaf
--- /dev/null
+++ b/komp.ipr
@@ -0,0 +1,186 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1.7
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/kotlin/nl/astraeus/komp/DomDiff.kt b/src/main/kotlin/nl/astraeus/komp/DomDiff.kt
new file mode 100644
index 0000000..eb94855
--- /dev/null
+++ b/src/main/kotlin/nl/astraeus/komp/DomDiff.kt
@@ -0,0 +1,65 @@
+package nl.astraeus.komp
+
+import org.w3c.dom.HTMLElement
+import org.w3c.dom.get
+
+/**
+ * User: rnentjes
+ * Date: 10-9-17
+ * Time: 13:33
+ */
+
+object DomDiffer {
+
+ fun replaceDiff(newElement: HTMLElement, oldElement: HTMLElement) {
+ if (!match(newElement, oldElement)) {
+ replaceNode(newElement, oldElement)
+ } else {
+ // think of the children!
+ for (index in 0 until newElement.childElementCount) {
+ val newChild = newElement.children[index]
+ val oldChild = oldElement.children[index]
+
+ if (newChild is HTMLElement && oldChild is HTMLElement) {
+ replaceDiff(newChild, oldChild)
+ }
+ }
+ }
+ }
+
+ private fun replaceNode(newElement: HTMLElement, oldElement: HTMLElement) {
+ val parent = oldElement.parentElement
+
+ parent?.replaceChild(newElement, oldElement)
+ }
+
+ fun match(newElement: HTMLElement, oldElement: HTMLElement): Boolean {
+ var result = true
+
+ result = result && newElement.namespaceURI == oldElement.namespaceURI
+ result = result && newElement.nodeName == oldElement.nodeName
+ result = result && newElement.childElementCount == oldElement.childElementCount
+
+ val newAttr = newElement.attributes
+ val oldAttr = oldElement.attributes
+
+ result = result && newAttr.length == oldAttr.length
+
+ if (result) {
+ for (index in 0 until newAttr.length) {
+ val attr = newAttr[index]
+
+ if (attr != null) {
+ result = result && newAttr.getNamedItem(attr.name)?.name == oldAttr.getNamedItem(attr.name)?.name
+ result = result && newAttr.getNamedItem(attr.name)?.value == oldAttr.getNamedItem(attr.name)?.value
+ }
+ if (!result) {
+ break
+ }
+ }
+ }
+
+ return result
+ }
+
+}
diff --git a/src/main/kotlin/nl/astraeus/komp/Komponent.kt b/src/main/kotlin/nl/astraeus/komp/Komponent.kt
index 332325c..4692447 100644
--- a/src/main/kotlin/nl/astraeus/komp/Komponent.kt
+++ b/src/main/kotlin/nl/astraeus/komp/Komponent.kt
@@ -114,6 +114,7 @@ abstract class Komponent {
val newElement = it.create()
parent?.replaceChild(newElement, element)
+ //DomDiffer.replaceDiff(newElement, element)
}
}
}