diff --git a/web/core/src/jsMain/kotlin/androidx/compose/web/css/properties/background.kt b/web/core/src/jsMain/kotlin/androidx/compose/web/css/properties/background.kt index 710c73fef6..b0dccaa35a 100644 --- a/web/core/src/jsMain/kotlin/androidx/compose/web/css/properties/background.kt +++ b/web/core/src/jsMain/kotlin/androidx/compose/web/css/properties/background.kt @@ -11,4 +11,9 @@ fun StyleBuilder.backgroundColor(value: String) { fun StyleBuilder.backgroundColor(value: CSSColorValue) { property("background-color", value) +} + +// https://developer.mozilla.org/en-US/docs/Web/CSS/background-attachment +fun StyleBuilder.backgroundAttachment(value: String) { + property("background-attachment", value) } \ No newline at end of file diff --git a/web/core/src/jsTest/kotlin/css/CSSBackgroundTests.kt b/web/core/src/jsTest/kotlin/css/CSSBackgroundTests.kt index 2bd397ddf5..2492c29a14 100644 --- a/web/core/src/jsTest/kotlin/css/CSSBackgroundTests.kt +++ b/web/core/src/jsTest/kotlin/css/CSSBackgroundTests.kt @@ -7,6 +7,7 @@ package org.jetbrains.compose.web.core.tests.css import kotlinx.browser.window import org.jetbrains.compose.web.core.tests.runTest +import org.jetbrains.compose.web.css.backgroundAttachment import org.jetbrains.compose.web.css.backgroundColor import org.jetbrains.compose.web.dom.Div import org.w3c.dom.HTMLElement @@ -29,4 +30,24 @@ class CSSBackgroundTests { assertEquals("rgb(0, 128, 0)", window.getComputedStyle(root.children[0] as HTMLElement).backgroundColor) assertEquals("rgba(0, 129, 0, 0.2)", window.getComputedStyle(root.children[1] as HTMLElement).backgroundColor) } + + @Test + fun backgroundAttachment() = runTest { + composition { + Div({style { + backgroundAttachment("scroll") + }}) + Div({style { + backgroundAttachment("fixed") + }}) + Div({style { + backgroundAttachment("local") + }}) + } + + assertEquals("scroll", window.getComputedStyle(root.children[0] as HTMLElement).backgroundAttachment) + assertEquals("fixed", window.getComputedStyle(root.children[1] as HTMLElement).backgroundAttachment) + assertEquals("local", window.getComputedStyle(root.children[2] as HTMLElement).backgroundAttachment) + } + } \ No newline at end of file