diff options
author | Robert Jaros <rjaros@finn.pl> | 2017-09-08 13:29:16 +0200 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2017-09-08 13:29:16 +0200 |
commit | 85b48891c61c604c952c8739b50bdae2998c44a7 (patch) | |
tree | 7281243392774153dfb7b700fb55bb9b169c8a4e /src/main/kotlin/pl/treksoft/kvision/snabbdom | |
parent | 2072d1b9c1b9d4f515cc1759b12ca19db7106d82 (diff) | |
download | kvision-85b48891c61c604c952c8739b50bdae2998c44a7.tar.gz kvision-85b48891c61c604c952c8739b50bdae2998c44a7.tar.bz2 kvision-85b48891c61c604c952c8739b50bdae2998c44a7.zip |
Added code analyzing with Detekt
Refactoring
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/snabbdom')
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/snabbdom/Types.kt | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/snabbdom/Types.kt b/src/main/kotlin/pl/treksoft/kvision/snabbdom/Types.kt index 789417e6..3bf68003 100644 --- a/src/main/kotlin/pl/treksoft/kvision/snabbdom/Types.kt +++ b/src/main/kotlin/pl/treksoft/kvision/snabbdom/Types.kt @@ -1,6 +1,11 @@ package pl.treksoft.kvision.snabbdom -import com.github.snabbdom.* +import com.github.snabbdom.Attrs +import com.github.snabbdom.Classes +import com.github.snabbdom.On +import com.github.snabbdom.Props +import com.github.snabbdom.VNodeData +import com.github.snabbdom.VNodeStyle import pl.treksoft.kvision.core.Widget external class Object @@ -10,16 +15,16 @@ fun obj(init: dynamic.() -> Unit): dynamic { } @Suppress("UnsafeCastFromDynamic") -private fun VNodeData(): VNodeData = js("({})") +private fun vNodeData(): VNodeData = js("({})") interface SnOn<T> : On { var self: T } -fun snOpt(block: VNodeData.() -> Unit) = (VNodeData()::apply)(block) +fun snOpt(block: VNodeData.() -> Unit) = (vNodeData()::apply)(block) @Suppress("UnsafeCastFromDynamic") -internal fun On(widget: Widget): SnOn<Widget> { +internal fun on(widget: Widget): SnOn<Widget> { val obj = js("({})") obj["self"] = widget return obj @@ -29,28 +34,28 @@ typealias StringPair = Pair<String, String> typealias StringBoolPair = Pair<String, Boolean> @Suppress("UnsafeCastFromDynamic") -fun snStyle(vararg pairs: StringPair): VNodeStyle { +fun snStyle(pairs: List<StringPair>): VNodeStyle { return obj { pairs.forEach { (key, value) -> this[key] = value } } } @Suppress("UnsafeCastFromDynamic") -fun snProps(vararg pairs: StringPair): Props { +fun snProps(pairs: List<StringPair>): Props { return obj { pairs.forEach { (key, value) -> this[key] = value } } } @Suppress("UnsafeCastFromDynamic") -fun snClasses(vararg pairs: StringBoolPair): Classes { +fun snClasses(pairs: List<StringBoolPair>): Classes { return obj { pairs.forEach { (key, value) -> this[key] = value } } } @Suppress("UnsafeCastFromDynamic") -fun snAttrs(vararg pairs: StringPair): Attrs { +fun snAttrs(pairs: List<StringPair>): Attrs { return obj { pairs.forEach { (key, value) -> this[key] = value } } |