aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/html
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2019-06-03 18:31:49 +0200
committerRobert Jaros <rjaros@finn.pl>2019-06-03 18:31:49 +0200
commitf9398d1ae7da496d3a290d7b225225d70a4bb174 (patch)
tree9deb7578e9814c3155adb8fe0ffa3d146cecc584 /src/main/kotlin/pl/treksoft/kvision/html
parentfc7f3588472423ce915113c8d2089e4df3793de0 (diff)
downloadkvision-f9398d1ae7da496d3a290d7b225225d70a4bb174.tar.gz
kvision-f9398d1ae7da496d3a290d7b225225d70a4bb174.tar.bz2
kvision-f9398d1ae7da496d3a290d7b225225d70a4bb174.zip
Refactor support for additional attributes from Tag up to the Widget class.
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/html')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Tag.kt43
1 files changed, 1 insertions, 42 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt b/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt
index d9d839ba..81d6848b 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt
@@ -25,8 +25,6 @@ import com.github.snabbdom.VNode
import pl.treksoft.kvision.KVManager
import pl.treksoft.kvision.core.Container
import pl.treksoft.kvision.core.StringBoolPair
-import pl.treksoft.kvision.core.StringPair
-import pl.treksoft.kvision.core.Widget
import pl.treksoft.kvision.i18n.I18n
import pl.treksoft.kvision.panel.SimplePanel
@@ -115,8 +113,6 @@ open class Tag(
init: (Tag.() -> Unit)? = null
) : SimplePanel(classes), Template {
- protected val attributes = attributes.toMutableMap()
-
/**
* Tag type.
*/
@@ -148,6 +144,7 @@ open class Tag(
override var templates: Map<String, (Any?) -> String> by refreshOnUpdate(mapOf())
init {
+ this.attributes += attributes
@Suppress("LeakingThis")
init?.invoke(this)
}
@@ -181,14 +178,6 @@ open class Tag(
return cl
}
- override fun getSnAttrs(): List<StringPair> {
- return if (attributes.isEmpty()) {
- super.getSnAttrs()
- } else {
- attributes.toList() + super.getSnAttrs()
- }
- }
-
operator fun String.unaryPlus() {
if (content == null)
content = this
@@ -196,36 +185,6 @@ open class Tag(
content += translate(this)
}
- /**
- * Returns the value of an additional attribute.
- * @param name the name of the attribute
- * @return the value of the attribute
- */
- fun getAttribute(name: String): String? {
- return this.attributes[name]
- }
-
- /**
- * Sets the value of additional attribute.
- * @param name the name of the attribute
- * @param value the value of the attribute
- */
- fun setAttribute(name: String, value: String): Widget {
- this.attributes[name] = value
- refresh()
- return this
- }
-
- /**
- * Removes the value of additional attribute.
- * @param name the name of the attribute
- */
- fun removeAttribute(name: String): Widget {
- this.attributes.remove(name)
- refresh()
- return this
- }
-
companion object {
/**
* DSL builder extension function.