From a4604d4a72115a348237bd0bb6a0cca67d5a8af9 Mon Sep 17 00:00:00 2001 From: Oleksandr Karpovich Date: Thu, 23 Dec 2021 10:48:54 +0100 Subject: [PATCH] web: make Nth.Functional, Nth.Odd, Nth.Even private (#1633) add corresponding public functions and values instead Co-authored-by: Oleksandr Karpovich --- .../compose/web/css/selectors/CSSSelectors.kt | 16 +++++++++++++--- web/core/src/jsTest/kotlin/css/NthChildTests.kt | 3 +-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/selectors/CSSSelectors.kt b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/selectors/CSSSelectors.kt index 1ac86a51b4b..66b9cd652d5 100644 --- a/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/selectors/CSSSelectors.kt +++ b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/selectors/CSSSelectors.kt @@ -8,7 +8,7 @@ internal const val webCssSelectorsDeprecationMessage = "Consider using a propert private val selectorScope = object : SelectorsScope {} sealed interface Nth { - data class Functional(val a: Int? = null, val b: Int? = null) : Nth { + private data class FunctionalImpl(val a: Int? = null, val b: Int? = null) : Nth { override fun toString(): String = when { a != null && b != null -> "${a}n+$b" a != null -> "${a}n" @@ -16,12 +16,22 @@ sealed interface Nth { else -> "" } } - object Odd : Nth { + private object OddImpl : Nth { override fun toString(): String = "odd" } - object Even : Nth { + private object EvenImpl : Nth { override fun toString(): String = "even" } + + companion object { + val Odd: Nth = OddImpl + val Even: Nth = EvenImpl + + @Suppress("FunctionName") // we want it to look like old Functional class constructor + fun Functional(a: Int? = null, b: Int? = null): Nth { + return FunctionalImpl(a = a, b = b) + } + } } abstract class CSSSelector internal constructor() { diff --git a/web/core/src/jsTest/kotlin/css/NthChildTests.kt b/web/core/src/jsTest/kotlin/css/NthChildTests.kt index 90598d5ae9e..45e3bafbf25 100644 --- a/web/core/src/jsTest/kotlin/css/NthChildTests.kt +++ b/web/core/src/jsTest/kotlin/css/NthChildTests.kt @@ -84,5 +84,4 @@ class NthChildTests { styleSheet.serializeRules() ) } - -} \ No newline at end of file +}