From 0c647a465b708829166010218fe0ae61f01de934 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Sat, 22 Jun 2019 20:18:56 +0200 Subject: An advanced option to strictly bind a component to the DOM element. --- src/main/kotlin/pl/treksoft/kvision/core/Widget.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/main/kotlin') 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 = 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 = 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()) -- cgit