Skip to content

Commit

Permalink
Added IE-specific values for textarea wrap attribute (#266)
Browse files Browse the repository at this point in the history
* Added IE-specific values for textarea wrap attribute

* Reworded deprecation message

* Regenerated TextAreaWrap with corrected deprecation message

* Updated gen-tag-unions.kt for code merged in from master
  • Loading branch information
severn-everett authored May 15, 2024
1 parent 8531fec commit 0832e98
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
6 changes: 4 additions & 2 deletions buildSrc/src/main/kotlin/kotlinx/html/generate/rules.kt
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ fun isEnumExcluded(name: String) = excludedEnums.any { it.containsMatchIn(name)

val contentlessTags = setOf("html", "head", "script", "style")

val deprecated = listOf(".*FormMethod#(put|patch|delete)" to "method is not allowed in browsers")
.map { it.first.toRegex(RegexOption.IGNORE_CASE) to it.second }
val deprecated = listOf(
".*FormMethod#(put|patch|delete)" to "method is not allowed in browsers",
".*TextAreaWrap#(virtual|physical|off)" to "value only supported in IE"
).map { it.first.toRegex(RegexOption.IGNORE_CASE) to it.second }

fun findEnumDeprecation(attribute: AttributeInfo, value: AttributeEnumValue): String? {
return deprecated.firstOrNull { p -> p.first.matches("""${attribute.enumTypeName}#${value.realName}""") }?.second
Expand Down
3 changes: 3 additions & 0 deletions buildSrc/src/main/resources/html_5.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -1706,6 +1706,9 @@
<xsd:restriction base="xsd:NMTOKEN">
<xsd:enumeration value="hard"/>
<xsd:enumeration value="soft"/>
<xsd:enumeration value="virtual"/>
<xsd:enumeration value="physical"/>
<xsd:enumeration value="off"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
Expand Down
5 changes: 4 additions & 1 deletion src/commonMain/kotlin/generated/gen-enums.kt
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,10 @@ object StyleMedia {
@Suppress("unused")
enum class TextAreaWrap(override val realValue : String) : AttributeEnum {
hard("hard"),
soft("soft")
soft("soft"),
@Deprecated("value only supported in IE") virtual("virtual"),
@Deprecated("value only supported in IE") physical("physical"),
@Deprecated("value only supported in IE") off("off")
}

internal val textAreaWrapValues : Map<String, TextAreaWrap> = TextAreaWrap.values().associateBy { it.realValue }
Expand Down
30 changes: 30 additions & 0 deletions src/commonMain/kotlin/generated/gen-tag-unions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1066,10 +1066,40 @@ inline fun FlowOrInteractiveOrPhrasingContent.softTextArea(rows : String? = null
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
TEXTAREA(attributesMapOf("rows", rows,"cols", cols,"wrap", TextAreaWrap.soft.realValue,"class", classes), consumer).visit(block)
}
@Suppress("DEPRECATION")
@HtmlTagMarker
@OptIn(ExperimentalContracts::class)
inline fun FlowOrInteractiveOrPhrasingContent.virtualTextArea(rows : String? = null, cols : String? = null, classes : String? = null, crossinline block : TEXTAREA.() -> Unit = {}) : Unit {
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
TEXTAREA(attributesMapOf("rows", rows,"cols", cols,"wrap", TextAreaWrap.virtual.realValue,"class", classes), consumer).visit(block)
}
@Suppress("DEPRECATION")
@HtmlTagMarker
@OptIn(ExperimentalContracts::class)
inline fun FlowOrInteractiveOrPhrasingContent.physicalTextArea(rows : String? = null, cols : String? = null, classes : String? = null, crossinline block : TEXTAREA.() -> Unit = {}) : Unit {
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
TEXTAREA(attributesMapOf("rows", rows,"cols", cols,"wrap", TextAreaWrap.physical.realValue,"class", classes), consumer).visit(block)
}
@Suppress("DEPRECATION")
@HtmlTagMarker
@OptIn(ExperimentalContracts::class)
inline fun FlowOrInteractiveOrPhrasingContent.offTextArea(rows : String? = null, cols : String? = null, classes : String? = null, crossinline block : TEXTAREA.() -> Unit = {}) : Unit {
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
TEXTAREA(attributesMapOf("rows", rows,"cols", cols,"wrap", TextAreaWrap.off.realValue,"class", classes), consumer).visit(block)
}
@HtmlTagMarker
fun FlowOrInteractiveOrPhrasingContent.hardTextArea(rows : String? = null, cols : String? = null, classes : String? = null, content : String = "") : Unit = TEXTAREA(attributesMapOf("rows", rows,"cols", cols,"wrap", TextAreaWrap.hard.realValue,"class", classes), consumer).visit({+content})
@HtmlTagMarker
fun FlowOrInteractiveOrPhrasingContent.softTextArea(rows : String? = null, cols : String? = null, classes : String? = null, content : String = "") : Unit = TEXTAREA(attributesMapOf("rows", rows,"cols", cols,"wrap", TextAreaWrap.soft.realValue,"class", classes), consumer).visit({+content})
@Suppress("DEPRECATION")
@HtmlTagMarker
fun FlowOrInteractiveOrPhrasingContent.virtualTextArea(rows : String? = null, cols : String? = null, classes : String? = null, content : String = "") : Unit = TEXTAREA(attributesMapOf("rows", rows,"cols", cols,"wrap", TextAreaWrap.virtual.realValue,"class", classes), consumer).visit({+content})
@Suppress("DEPRECATION")
@HtmlTagMarker
fun FlowOrInteractiveOrPhrasingContent.physicalTextArea(rows : String? = null, cols : String? = null, classes : String? = null, content : String = "") : Unit = TEXTAREA(attributesMapOf("rows", rows,"cols", cols,"wrap", TextAreaWrap.physical.realValue,"class", classes), consumer).visit({+content})
@Suppress("DEPRECATION")
@HtmlTagMarker
fun FlowOrInteractiveOrPhrasingContent.offTextArea(rows : String? = null, cols : String? = null, classes : String? = null, content : String = "") : Unit = TEXTAREA(attributesMapOf("rows", rows,"cols", cols,"wrap", TextAreaWrap.off.realValue,"class", classes), consumer).visit({+content})

/**
* Video player
Expand Down

0 comments on commit 0832e98

Please sign in to comment.