Repository: JetBrains/compose-multiplatform
File: html/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/StyleScope.kt (Kotlin)

Code before:
        properties.add(StylePropertyDeclaration(propertyName, value, important))
    }

    override fun variable(variableName: String, value: StylePropertyValue) {
        variables.add(StylePropertyDeclaration(variableName, value))
    }

    // StylePropertyValue is js native object without equals
    override fun equals(other: Any?): Boolean {
        return if (other is StyleHolder) {
            properties.nativeEquals(other.properties) &&
                variables.nativeEquals(other.variables)
        } else false
    }

    @ComposeWebInternalApi
    internal fun copyFrom(sb: StyleHolder) {
        properties.addAll(sb.properties)
        variables.addAll(sb.variables)
    }
}

data class StylePropertyDeclaration(
    val name: String,
    val value: StylePropertyValue,
    val important: Boolean = false,
) {
    constructor(name: String, value: String, important: Boolean = false) : this(name, value.unsafeCast<StylePropertyValue>(), important)
    constructor(name: String, value: Number, important: Boolean = false) : this(name, value.unsafeCast<StylePropertyValue>(), important)
}
typealias StylePropertyList = List<StylePropertyDeclaration>
typealias MutableStylePropertyList = MutableList<StylePropertyDeclaration>

internal fun StylePropertyList.nativeEquals(properties: StylePropertyList): Boolean {
    if (this.size != properties.size) return false

    var index = 0
    return all { prop ->
        val otherProp = properties[index++]
        prop.name == otherProp.name &&
            prop.value.toString() == otherProp.value.toString() &&
                prop.important == otherProp.important
    }
}


Review comment (suggestion):
Adding a new parameter here makes the constructors not binary compatible, because Kotlin doesn't create the overloads - it adds an extra bitmask parameter to indicate the presence of default values.

I guess that the only way is to add the overloads for every constructor and keep the new property separately + override the equals() and hashCode(). 

___

I think ideally this class would be a regular class not a `data` class, but we can't change it now because we want to keep it compatible.

Code after:
    @ComposeWebInternalApi
    val properties: StylePropertyList
    @ComposeWebInternalApi
    val variables: StylePropertyList
}

@Deprecated(
    message = "Renamed to StyleScopeBuilder",
    replaceWith = ReplaceWith("StyleScopeBuilder", "org.jetbrains.compose.web.css.StyleScopeBuilder")
)
typealias StyleBuilderImpl = StyleScopeBuilder

@Suppress("EqualsOrHashCode")
open class StyleScopeBuilder : StyleScope, StyleHolder {
    override val properties: MutableStylePropertyList = mutableListOf()
    override val variables: MutableStylePropertyList = mutableListOf()

    override fun property(propertyName: String, value: StylePropertyValue, important: Boolean) {
        properties.add(StylePropertyDeclaration(propertyName, value, important))
    }

    override fun property(propertyName: String, value: StylePropertyValue) {
        property(propertyName = propertyName, value = value, important = false)
    }

    override fun variable(variableName: String, value: StylePropertyValue) {
        variables.add(StylePropertyDeclaration(variableName, value))
    }

    // StylePropertyValue is js native object without equals
    override fun equals(other: Any?): Boolean {
        return if (other is StyleHolder) {
            properties.nativeEquals(other.properties) &&
                variables.nativeEquals(other.variables)
        } else false
    }

    @ComposeWebInternalApi
    internal fun copyFrom(sb: StyleHolder) {
        properties.addAll(sb.properties)
        variables.addAll(sb.variables)
    }
}

data class StylePropertyDeclaration(
    val name: String,
    val value: StylePropertyValue,
    val important: Boolean,
) {
    constructor(name: String, value: StylePropertyValue) : this(name, value, false)