Browse Source

Don't store any attribute values but rather reset one that needed and remove the rest

UPDATE_ATTRS_NO_MEMORY
Shagen Ogandzhanian 3 years ago
parent
commit
5650db5e88
  1. 13
      web/core/src/jsMain/kotlin/org/jetbrains/compose/web/DomApplier.kt

13
web/core/src/jsMain/kotlin/org/jetbrains/compose/web/DomApplier.kt

@ -90,17 +90,18 @@ internal open class DomNodeWrapper(open val node: Node) {
internal class DomElementWrapper(override val node: HTMLElement): DomNodeWrapper(node) {
private var currentAttrs: Map<String, String>? = null
fun updateAttrs(attrs: Map<String, String>) {
currentAttrs?.forEach {
node.removeAttribute(it.key)
attrs.forEach { (name, value) ->
node.setAttribute(name, value)
}
attrs.forEach {
node.setAttribute(it.key, it.value)
node.getAttributeNames().forEach { name ->
if (name == "style") return
if (!attrs.containsKey(name)) {
node.removeAttribute(name)
}
}
currentAttrs = attrs
}
fun updateProperties(list: List<Pair<(Element, Any) -> Unit, Any>>) {

Loading…
Cancel
Save