From 73f1022ac23ae282a236bff5c9b68029428352e7 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Fri, 15 May 2020 16:55:22 +0200 Subject: Allow nullable src property for the Image component. --- src/main/kotlin/pl/treksoft/kvision/html/Image.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/main/kotlin') diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Image.kt b/src/main/kotlin/pl/treksoft/kvision/html/Image.kt index f21d515f..e7ecf393 100644 --- a/src/main/kotlin/pl/treksoft/kvision/html/Image.kt +++ b/src/main/kotlin/pl/treksoft/kvision/html/Image.kt @@ -50,7 +50,7 @@ enum class ImageShape(internal val className: String) { * @param classes a set of CSS class names */ open class Image( - src: ResString, alt: String? = null, responsive: Boolean = false, shape: ImageShape? = null, + src: ResString?, alt: String? = null, responsive: Boolean = false, shape: ImageShape? = null, centered: Boolean = false, classes: Set = setOf() ) : Widget(classes) { /** @@ -84,7 +84,9 @@ open class Image( override fun getSnAttrs(): List { val pr = super.getSnAttrs().toMutableList() - pr.add("src" to src) + src?.let { + pr.add("src" to it) + } alt?.let { pr.add("alt" to translate(it)) } @@ -112,7 +114,7 @@ open class Image( * It takes the same parameters as the constructor of the built component. */ fun Container.image( - src: ResString, alt: String? = null, responsive: Boolean = false, shape: ImageShape? = null, + src: ResString?, alt: String? = null, responsive: Boolean = false, shape: ImageShape? = null, centered: Boolean = false, classes: Set? = null, className: String? = null, -- cgit