Browse Source

web: make Nth.Functional, Nth.Odd, Nth.Even private (#1633)

add corresponding public functions and values instead

Co-authored-by: Oleksandr Karpovich <oleksandr.karpovich@jetbrains.com>
pull/1681/head v1.0.1
Oleksandr Karpovich 3 years ago committed by GitHub
parent
commit
a4604d4a72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/selectors/CSSSelectors.kt
  2. 3
      web/core/src/jsTest/kotlin/css/NthChildTests.kt

16
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() {

3
web/core/src/jsTest/kotlin/css/NthChildTests.kt

@ -84,5 +84,4 @@ class NthChildTests {
styleSheet.serializeRules()
)
}
}
}

Loading…
Cancel
Save