Browse Source

Remove unnecessary parameter to required (#1988)

* Remove unnecessary parameter to required

As [`required` is a boolean attribute](https://html.spec.whatwg.org/multipage/input.html#the-required-attribute), `required(false)` would confusingly make the input required.

* Add back old function and deprecate it
pull/2302/head
Veyndan Stuart 2 years ago committed by GitHub
parent
commit
dd857bd1b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      web/core/src/jsMain/kotlin/org/jetbrains/compose/web/attributes/Attrs.kt

8
web/core/src/jsMain/kotlin/org/jetbrains/compose/web/attributes/Attrs.kt

@ -194,9 +194,17 @@ fun AttrsScope<HTMLInputElement>.placeholder(value: String) =
fun AttrsScope<HTMLInputElement>.readOnly() =
attr("readonly", "")
@Deprecated(
message = "Please use `required()` without parameters. Use if..else.. if conditional behaviour required.",
replaceWith = ReplaceWith("required()", "org.jetbrains.compose.web.attributes.required"),
level = DeprecationLevel.WARNING
)
fun AttrsScope<HTMLInputElement>.required(value: Boolean = true) =
attr("required", value.toString())
fun AttrsScope<HTMLInputElement>.required() =
attr("required", "")
fun AttrsScope<HTMLInputElement>.size(value: Int) =
attr("size", value.toString())

Loading…
Cancel
Save