From 019cbd2940a7540670a784606c8ac418516b0789 Mon Sep 17 00:00:00 2001 From: Shagen Ogandzhanian Date: Tue, 22 Jun 2021 19:17:31 +0200 Subject: [PATCH] Use CSSStyleSheet so that there's no need to define additional functionality on Stylesheet --- .../androidx/compose/web/css/BrowserAPI.kt | 24 -------------- .../androidx/compose/web/elements/Style.kt | 33 ++++++++++--------- 2 files changed, 18 insertions(+), 39 deletions(-) diff --git a/web/core/src/jsMain/kotlin/androidx/compose/web/css/BrowserAPI.kt b/web/core/src/jsMain/kotlin/androidx/compose/web/css/BrowserAPI.kt index 2ba67589af..325dd02f41 100644 --- a/web/core/src/jsMain/kotlin/androidx/compose/web/css/BrowserAPI.kt +++ b/web/core/src/jsMain/kotlin/androidx/compose/web/css/BrowserAPI.kt @@ -6,30 +6,6 @@ @file:Suppress("UNUSED", "NOTHING_TO_INLINE", "FunctionName") package org.jetbrains.compose.web.css -import org.w3c.dom.css.* -import org.w3c.dom.css.StyleSheet - -inline val StyleSheet.cssRules - get() = this.asDynamic().cssRules.unsafeCast() - - -inline fun StyleSheet.deleteRule(index: Int) { - this.asDynamic().deleteRule(index) -} - -fun StyleSheet.insertRule(cssRule: String, index: Int? = null): Int { - return if (index != null) { - this.asDynamic().insertRule(cssRule, index).unsafeCast() - } else { - this.asDynamic().insertRule(cssRule).unsafeCast() - } -} - - -inline operator fun CSSRuleList.get(index: Int): CSSRule { - return this.asDynamic()[index].unsafeCast() -} - @Suppress("NOTHING_TO_INLINE") inline fun jsObject(): T = js("({})") diff --git a/web/core/src/jsMain/kotlin/androidx/compose/web/elements/Style.kt b/web/core/src/jsMain/kotlin/androidx/compose/web/elements/Style.kt index 3bccae89e8..afa54b0c1a 100644 --- a/web/core/src/jsMain/kotlin/androidx/compose/web/elements/Style.kt +++ b/web/core/src/jsMain/kotlin/androidx/compose/web/elements/Style.kt @@ -9,6 +9,7 @@ import org.w3c.dom.css.CSSStyleDeclaration import org.w3c.dom.css.CSSStyleRule import org.w3c.dom.css.StyleSheet import org.jetbrains.compose.web.css.* +import org.w3c.dom.css.CSSStyleSheet /** * Use this function to mount the