diff options
author | Robert Jaros <rjaros@finn.pl> | 2020-03-04 18:26:32 +0100 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2020-03-04 18:26:32 +0100 |
commit | 503a424b61e55cf680db1c0115de7efaa9d385a8 (patch) | |
tree | 46b18b52dc405cdb11bc719b5fb57fc350709883 /src/main/kotlin/pl/treksoft/kvision | |
parent | 2c0d996ed9c69c685b1f1268f0d53778dba818ea (diff) | |
download | kvision-503a424b61e55cf680db1c0115de7efaa9d385a8.tar.gz kvision-503a424b61e55cf680db1c0115de7efaa9d385a8.tar.bz2 kvision-503a424b61e55cf680db1c0115de7efaa9d385a8.zip |
Fix internal event listeners order (#143)
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision')
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/core/Widget.kt | 18 |
1 files changed, 11 insertions, 7 deletions
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<String> = 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<Int, SnOn<Widget>.() -> 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()) { |