From 031d07d97a0a986cdff62ee9d802381139661f0e Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 25 Feb 2022 00:22:17 +0600 Subject: [PATCH] AttributesCollection#plus --- CHANGELOG.md | 1 + .../kotlin/dev/inmo/jsuikit/utils/AttributesCollection.kt | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 09565f3..de37b16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 0.0.38 * Add support of `Toggle` +* Attributes collection now can be concatenated ## 0.0.37 diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/utils/AttributesCollection.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/utils/AttributesCollection.kt index b44ada7..c71d37d 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/utils/AttributesCollection.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/utils/AttributesCollection.kt @@ -15,6 +15,13 @@ class AttributesCollection ( attrs() } + operator fun plus(other: AttributesCollection) = AttributesCollection( + *(modifiers + other.modifiers).distinct().toTypedArray() + ) { + this@AttributesCollection.attrs.invoke(this) + other.attrs.invoke(this) + } + companion object { val Empty = Attrs()