diff options
author | Robert Jaros <rjaros@finn.pl> | 2019-07-09 20:08:05 +0200 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2019-07-09 20:08:05 +0200 |
commit | d1612a42ec508f3ef0f61163d181e01931b9157c (patch) | |
tree | e2f8da4c115c156a01caa9aa7c419a0084cba047 | |
parent | d0ea8ade727c756aab6c878773fb2873ec41cd23 (diff) | |
download | kvision-d1612a42ec508f3ef0f61163d181e01931b9157c.tar.gz kvision-d1612a42ec508f3ef0f61163d181e01931b9157c.tar.bz2 kvision-d1612a42ec508f3ef0f61163d181e01931b9157c.zip |
New DOM bindings. Drop horrible "strictDOM" property.
13 files changed, 4 insertions, 42 deletions
diff --git a/kvision-modules/kvision-datetime/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt b/kvision-modules/kvision-datetime/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt index 5858d04b..8de8d088 100644 --- a/kvision-modules/kvision-datetime/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt +++ b/kvision-modules/kvision-datetime/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt @@ -54,7 +54,6 @@ open class DateTimeInput( private var initialized = false init { - this.vnkey = "kv_datetimeinput_${counter++}" this.setInternalEventListener<DateTimeInput> { change = { self.changeValue() @@ -294,7 +293,6 @@ open class DateTimeInput( } companion object { - internal var counter = 0 private fun String.toDatePickerFormat(): String { return this.replace("YY", "yy").replace("m", "i").replace("MMMM", "{----}").replace("MMM", "{---}") diff --git a/kvision-modules/kvision-select/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt b/kvision-modules/kvision-select/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt index 9ae1a4e9..e0a49326 100644 --- a/kvision-modules/kvision-select/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt +++ b/kvision-modules/kvision-select/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt @@ -130,7 +130,6 @@ open class SelectInput( override var size: InputSize? by refreshOnUpdate() init { - this.vnkey = "kv_selectinput_${counter++}" setChildrenFromOptions() this.setInternalEventListener<SelectInput> { change = { @@ -349,7 +348,6 @@ open class SelectInput( } companion object { - internal var counter = 0 /** * DSL builder extension function. diff --git a/kvision-modules/kvision-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt b/kvision-modules/kvision-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt index 66e98ab5..18df26fa 100644 --- a/kvision-modules/kvision-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt +++ b/kvision-modules/kvision-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt @@ -74,7 +74,6 @@ open class SpinnerInput( ) : Widget(classes + "form-control"), FormInput { init { - this.vnkey = "kv_spinnerinput_${counter++}" this.addSurroundingCssClass("input-group") if (buttonsType == ButtonsType.NONE) { this.addSurroundingCssClass("kv-spinner-btn-none") @@ -305,7 +304,6 @@ open class SpinnerInput( } companion object { - internal var counter = 0 /** * DSL builder extension function. diff --git a/kvision-modules/kvision-tabulator/src/main/kotlin/pl/treksoft/kvision/tabulator/Tabulator.kt b/kvision-modules/kvision-tabulator/src/main/kotlin/pl/treksoft/kvision/tabulator/Tabulator.kt index f87af393..a179b9ec 100644 --- a/kvision-modules/kvision-tabulator/src/main/kotlin/pl/treksoft/kvision/tabulator/Tabulator.kt +++ b/kvision-modules/kvision-tabulator/src/main/kotlin/pl/treksoft/kvision/tabulator/Tabulator.kt @@ -72,7 +72,6 @@ open class Tabulator<T : Any>( protected var filter: ((T) -> Boolean)? = null init { - this.vnkey = "kv_tabulator_$counter" if (data != null) { @Suppress("UnsafeCastFromDynamic") options.data = data.toTypedArray() diff --git a/kvision-modules/kvision-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt b/kvision-modules/kvision-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt index 39c4c4c6..21073e61 100644 --- a/kvision-modules/kvision-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt +++ b/kvision-modules/kvision-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt @@ -138,10 +138,6 @@ open class UploadInput(uploadUrl: String? = null, multiple: Boolean = false, cla private val nativeFiles: MutableMap<KFile, File> = mutableMapOf() - init { - this.vnkey = "kv_uploadinput_${counter++}" - } - override fun render(): VNode { return render("input") } @@ -316,7 +312,6 @@ open class UploadInput(uploadUrl: String? = null, multiple: Boolean = false, cla } companion object { - internal var counter = 0 /** * DSL builder extension function. diff --git a/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt b/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt index 2b2c7ef1..e17d7ba9 100644 --- a/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt +++ b/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt @@ -86,10 +86,6 @@ 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) @@ -101,7 +97,7 @@ open class Widget(classes: Set<String> = setOf()) : StyledComponent(), Component var eventTarget: Widget? = null - protected var vnkey: String? by refreshOnUpdate() + private var vnkey = "kv_widget_${counter++}" protected var vnode: VNode? = null private var snAttrsCache: List<StringPair>? = null @@ -188,11 +184,7 @@ open class Widget(classes: Set<String> = setOf()) : StyledComponent(), Component */ private fun getSnOpt(): VNodeData { return snOpt { - if (vnkey != null) { - key = vnkey - } else if (strictDOM) { - key = hashCode().toString() - } + key = vnkey attrs = snAttrs(getSnAttrsInternal()) style = snStyle(getSnStyleInternal()) `class` = snClasses(getSnClassInternal()) @@ -819,6 +811,8 @@ open class Widget(classes: Set<String> = setOf()) : StyledComponent(), Component } companion object { + private var counter: Long = 0 + /** * DSL builder extension function. * diff --git a/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt b/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt index b58860ff..a521fe95 100644 --- a/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt +++ b/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt @@ -149,7 +149,6 @@ open class DropDown( internal val list: DropDownListTag = DropDownListTag(idc, setOf("dropdown-menu")) init { - this.vnkey = "kv_dropdown_$counter" setChildrenFromElements() this.addInternal(button) this.addInternal(list) diff --git a/src/main/kotlin/pl/treksoft/kvision/form/check/CheckInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/check/CheckInput.kt index 07b86b4c..a486b82e 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/check/CheckInput.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/check/CheckInput.kt @@ -51,7 +51,6 @@ abstract class CheckInput( ) : Widget(classes), FormInput { init { - this.vnkey = "kv_checkinput_${counter++}" this.setInternalEventListener<CheckInput> { click = { val v = getElementJQuery()?.prop("checked") as Boolean? @@ -162,8 +161,4 @@ abstract class CheckInput( override fun blur() { getElementJQuery()?.blur() } - - companion object { - internal var counter = 0 - } } diff --git a/src/main/kotlin/pl/treksoft/kvision/form/select/SimpleSelectInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/select/SimpleSelectInput.kt index df334c1c..b2ba1d43 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/select/SimpleSelectInput.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/select/SimpleSelectInput.kt @@ -85,7 +85,6 @@ open class SimpleSelectInput( override var size: InputSize? by refreshOnUpdate() init { - this.vnkey = "kv_simpleselectinput_${counter++}" setChildrenFromOptions() this.setInternalEventListener<SimpleSelectInput> { change = { @@ -194,7 +193,6 @@ open class SimpleSelectInput( } companion object { - internal var counter = 0 /** * DSL builder extension function. diff --git a/src/main/kotlin/pl/treksoft/kvision/form/text/AbstractTextInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/text/AbstractTextInput.kt index 393ae63f..e7ecba8a 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/text/AbstractTextInput.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/text/AbstractTextInput.kt @@ -41,7 +41,6 @@ abstract class AbstractTextInput( ) : Widget(classes), FormInput { init { - this.vnkey = "kv_textinput_${counter++}" this.setInternalEventListener<AbstractTextInput> { input = { self.changeValue() @@ -167,8 +166,4 @@ abstract class AbstractTextInput( override fun blur() { getElementJQuery()?.blur() } - - companion object { - internal var counter = 0 - } } diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Canvas.kt b/src/main/kotlin/pl/treksoft/kvision/html/Canvas.kt index 476ee118..feb9a970 100644 --- a/src/main/kotlin/pl/treksoft/kvision/html/Canvas.kt +++ b/src/main/kotlin/pl/treksoft/kvision/html/Canvas.kt @@ -53,10 +53,6 @@ open class Canvas( */ lateinit var context2D: CanvasRenderingContext2D - init { - this.vnkey = "kv_canvas_${counter++}" - } - override fun render(): VNode { return render("canvas") } diff --git a/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt b/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt index 5d872b08..5f911539 100644 --- a/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt +++ b/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt @@ -110,7 +110,6 @@ open class Modal( private val footer = SimplePanel(setOf("modal-footer")) init { - this.vnkey = "kv_modal_${counter++}" this.hide() this.role = "dialog" this.addInternal(dialog) @@ -271,7 +270,6 @@ open class Modal( } companion object { - internal var counter = 0 internal var modals = mutableListOf<Modal>() } } diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt index 7b046e1a..8b46ae0b 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt @@ -123,7 +123,6 @@ internal class Splitter(private val splitPanel: SplitPanel, direction: Direction private val idc = "kv_splitter_$counter" init { - this.vnkey = "kv_splitter_$counter" this.id = idc counter++ } |