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 1ac86a51b4..66b9cd652d 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 90598d5ae9..45e3bafbf2 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 +}