Skip to content

Commit

Permalink
web: make Nth.Functional, Nth.Odd, Nth.Even private (#1633)
Browse files Browse the repository at this point in the history
add corresponding public functions and values instead

Co-authored-by: Oleksandr Karpovich <[email protected]>
  • Loading branch information
eymar and Oleksandr Karpovich authored Dec 23, 2021
1 parent abc6d1f commit a4604d4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,30 @@ 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"
b != null -> "$b"
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() {
Expand Down
3 changes: 1 addition & 2 deletions web/core/src/jsTest/kotlin/css/NthChildTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,4 @@ class NthChildTests {
styleSheet.serializeRules()
)
}

}
}

0 comments on commit a4604d4

Please sign in to comment.