Browse Source

web: add HtmlAttrMarker (#1958)

To forbid declaring of attrs is style scope

closes #1893

Co-authored-by: Oleksandr Karpovich <oleksandr.karpovich@jetbrains.com>
pull/1973/head
Oleksandr Karpovich 3 years ago committed by GitHub
parent
commit
f1854a9dce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      web/core/src/jsMain/kotlin/org/jetbrains/compose/web/attributes/AttrsScope.kt
  2. 4
      web/core/src/jsMain/kotlin/org/jetbrains/compose/web/attributes/HtmlAttrMarker.kt
  3. 2
      web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/StyleScope.kt

3
web/core/src/jsMain/kotlin/org/jetbrains/compose/web/attributes/AttrsScope.kt

@ -27,7 +27,8 @@ typealias AttrsBuilder<T> = AttrsScopeBuilder<T>
* are extracted to a separate methods. * are extracted to a separate methods.
* *
*/ */
interface AttrsScope<TElement : Element>: EventsListenerScope { @HtmlAttrMarker
interface AttrsScope<TElement : Element> : EventsListenerScope {
/** /**
* [style] add inline CSS-style properties to the element via [StyleScope] context * [style] add inline CSS-style properties to the element via [StyleScope] context
* *

4
web/core/src/jsMain/kotlin/org/jetbrains/compose/web/attributes/HtmlAttrMarker.kt

@ -0,0 +1,4 @@
package org.jetbrains.compose.web.attributes
@DslMarker
annotation class HtmlAttrMarker

2
web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/StyleScope.kt

@ -7,6 +7,7 @@
package org.jetbrains.compose.web.css package org.jetbrains.compose.web.css
import org.jetbrains.compose.web.attributes.HtmlAttrMarker
import org.jetbrains.compose.web.internal.runtime.ComposeWebInternalApi import org.jetbrains.compose.web.internal.runtime.ComposeWebInternalApi
import kotlin.properties.ReadOnlyProperty import kotlin.properties.ReadOnlyProperty
@ -22,6 +23,7 @@ typealias StyleBuilder = StyleScope
* 1. Add inlined css properties to the element (@see [property]) * 1. Add inlined css properties to the element (@see [property])
* 2. Set values to CSS variables (@see [variable]) * 2. Set values to CSS variables (@see [variable])
*/ */
@HtmlAttrMarker
interface StyleScope { interface StyleScope {
/** /**
* Adds arbitrary CSS property to the inline style of the element * Adds arbitrary CSS property to the inline style of the element

Loading…
Cancel
Save