Fix Komponent.create, v. 0.5.8
Took 7 minutes
This commit is contained in:
@@ -112,7 +112,7 @@ private fun Element.getKompAttributes(): MutableSet<String> {
|
||||
return result
|
||||
}
|
||||
|
||||
private fun Element.setKompAttribute(name: String, value: String) {
|
||||
fun Element.setKompAttribute(name: String, value: String) {
|
||||
val setAttrs: MutableSet<String> = 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!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<String, CSSStyleDeclaration> = HashMap()
|
||||
|
||||
open fun create(parent: Element, childIndex: Int? = null) {
|
||||
onBeforeUpdate()
|
||||
val builder = HtmlBuilder(
|
||||
parent,
|
||||
childIndex ?: parent.childElementCount
|
||||
childIndex ?: parent.childNodes.length
|
||||
)
|
||||
|
||||
builder.render()
|
||||
|
||||
Reference in New Issue
Block a user