diff options
author | Robert Jaros <rjaros@finn.pl> | 2019-06-22 20:18:56 +0200 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2019-06-22 20:18:56 +0200 |
commit | 0c647a465b708829166010218fe0ae61f01de934 (patch) | |
tree | 8e3bfc80b15229719b34cb34658fcc536a0bfb62 | |
parent | 848a7470864eb245158700c3bb83c06fb56f9a6a (diff) | |
download | kvision-0c647a465b708829166010218fe0ae61f01de934.tar.gz kvision-0c647a465b708829166010218fe0ae61f01de934.tar.bz2 kvision-0c647a465b708829166010218fe0ae61f01de934.zip |
An advanced option to strictly bind a component to the DOM element.
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/core/Widget.kt | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt b/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt index fbcd89da..414356ce 100644 --- a/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt +++ b/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt @@ -86,6 +86,10 @@ open class Widget(classes: Set<String> = setOf()) : StyledComponent(), Component * Determines if the current widget is draggable. */ var draggable: Boolean? by refreshOnUpdate() + /** + * Determines if the current widget is strictly bound to the DOM. + */ + var strictDOM: Boolean by refreshOnUpdate(false) protected var surroundingSpan by refreshOnUpdate(false) @@ -184,7 +188,11 @@ open class Widget(classes: Set<String> = setOf()) : StyledComponent(), Component */ private fun getSnOpt(): VNodeData { return snOpt { - if (vnkey != null) key = vnkey + if (vnkey != null) { + key = vnkey + } else if (strictDOM) { + key = hashCode().toString() + } attrs = snAttrs(getSnAttrsInternal()) style = snStyle(getSnStyleInternal()) `class` = snClasses(getSnClassInternal()) |