From 503a424b61e55cf680db1c0115de7efaa9d385a8 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Wed, 4 Mar 2020 18:26:32 +0100 Subject: Fix internal event listeners order (#143) --- src/main/kotlin/pl/treksoft/kvision/core/Widget.kt | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/main') diff --git a/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt b/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt index b74352d3..918d0ad0 100644 --- a/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt +++ b/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt @@ -262,14 +262,18 @@ open class Widget(classes: Set = setOf()) : StyledComponent(), Component * @return list of event handlers */ protected open fun getSnOn(): com.github.snabbdom.On? { - val map = listenersMap.filter { it.key != "self" && it.value.isNotEmpty() }.toMutableMap() - internalListenersMap.filter { it.key != "self" && it.value.isNotEmpty() } - .forEach { (event, internalListeners) -> - val listeners = map[event] - if (listeners != null) { - listeners.putAll(internalListeners) + val map = internalListenersMap.filter { it.key != "self" && it.value.isNotEmpty() }.map { + val internalListeners = mutableMapOf.() -> Unit>() + internalListeners.putAll(it.value) + it.key to internalListeners + }.toMap().toMutableMap() + listenersMap.filter { it.key != "self" && it.value.isNotEmpty() } + .forEach { (event, listeners) -> + val internalListeners = map[event] + if (internalListeners != null) { + internalListeners.putAll(listeners) } else { - map[event] = internalListeners + map[event] = listeners } } return if (map.isNotEmpty()) { -- cgit