Skip to content

Commit

Permalink
Using correct string type for input attribute "autocomplete" (#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
severn-everett committed Jun 25, 2024
1 parent b4a6eae commit 363b34e
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 16 deletions.
77 changes: 69 additions & 8 deletions buildSrc/src/main/resources/html_5.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -1433,14 +1433,7 @@
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="autocomplete">
<xsd:simpleType>
<xsd:restriction base="xsd:NMTOKEN">
<xsd:enumeration value="on"/>
<xsd:enumeration value="off"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="autocomplete" type="autocompleteType" />
<xsd:attribute name="checked">
<xsd:simpleType>
<xsd:restriction base="xsd:NMTOKEN">
Expand Down Expand Up @@ -2033,6 +2026,74 @@
</xsd:union>
</xsd:simpleType>

<xsd:simpleType name="autocompleteType">
<xsd:union>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="on"/>
<xsd:enumeration value="off"/>
<xsd:enumeration value="address-line1"/>
<xsd:enumeration value="address-line2"/>
<xsd:enumeration value="address-line3"/>
<xsd:enumeration value="address-level1"/>
<xsd:enumeration value="address-level2"/>
<xsd:enumeration value="address-level3"/>
<xsd:enumeration value="address-level4"/>
<xsd:enumeration value="street-address"/>
<xsd:enumeration value="country"/>
<xsd:enumeration value="country-name"/>
<xsd:enumeration value="postal-code"/>
<xsd:enumeration value="name"/>
<xsd:enumeration value="additional-name"/>
<xsd:enumeration value="family-name"/>
<xsd:enumeration value="given-name"/>
<xsd:enumeration value="honoric-prefix"/>
<xsd:enumeration value="honoric-suffix"/>
<xsd:enumeration value="nickname"/>
<xsd:enumeration value="organization-title"/>
<xsd:enumeration value="username"/>
<xsd:enumeration value="new-password"/>
<xsd:enumeration value="current-password"/>
<xsd:enumeration value="bday"/>
<xsd:enumeration value="bday-day"/>
<xsd:enumeration value="bday-month"/>
<xsd:enumeration value="bday-year"/>
<xsd:enumeration value="sex"/>
<xsd:enumeration value="one-time-code"/>
<xsd:enumeration value="organization"/>
<xsd:enumeration value="cc-name"/>
<xsd:enumeration value="cc-given-name"/>
<xsd:enumeration value="cc-additional-name"/>
<xsd:enumeration value="cc-family-name"/>
<xsd:enumeration value="cc-number"/>
<xsd:enumeration value="cc-exp"/>
<xsd:enumeration value="cc-exp-month"/>
<xsd:enumeration value="cc-exp-year"/>
<xsd:enumeration value="cc-csc"/>
<xsd:enumeration value="cc-type"/>
<xsd:enumeration value="transaction-currency"/>
<xsd:enumeration value="transaction-amount"/>
<xsd:enumeration value="language"/>
<xsd:enumeration value="url"/>
<xsd:enumeration value="email"/>
<xsd:enumeration value="photo"/>
<xsd:enumeration value="tel"/>
<xsd:enumeration value="tel-country-code"/>
<xsd:enumeration value="tel-national"/>
<xsd:enumeration value="tel-area-code"/>
<xsd:enumeration value="tel-local"/>
<xsd:enumeration value="tel-local-prefix"/>
<xsd:enumeration value="tel-local-suffix"/>
<xsd:enumeration value="tel-extension"/>
<xsd:enumeration value="impp"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType>
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
</xsd:union>
</xsd:simpleType>

<xsd:complexType mixed="true" name="simpleFlowContentElement">
<xsd:choice>
<xsd:group ref="flowContent"/>
Expand Down
62 changes: 62 additions & 0 deletions src/commonMain/kotlin/generated/gen-enums.kt
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,68 @@ enum class InputType(override val realValue : String) : AttributeEnum {
}

internal val inputTypeValues : Map<String, InputType> = InputType.entries.associateBy { it.realValue }
@Suppress("unused", "ConstPropertyName")
object InputAutoComplete {
const val on : String = "on"
const val off : String = "off"
const val addressLine1 : String = "address-line1"
const val addressLine2 : String = "address-line2"
const val addressLine3 : String = "address-line3"
const val addressLevel1 : String = "address-level1"
const val addressLevel2 : String = "address-level2"
const val addressLevel3 : String = "address-level3"
const val addressLevel4 : String = "address-level4"
const val streetAddress : String = "street-address"
const val country : String = "country"
const val countryName : String = "country-name"
const val postalCode : String = "postal-code"
const val name : String = "name"
const val additionalName : String = "additional-name"
const val familyName : String = "family-name"
const val givenName : String = "given-name"
const val honoricPrefix : String = "honoric-prefix"
const val honoricSuffix : String = "honoric-suffix"
const val nickname : String = "nickname"
const val organizationTitle : String = "organization-title"
const val username : String = "username"
const val newPassword : String = "new-password"
const val currentPassword : String = "current-password"
const val bday : String = "bday"
const val bdayDay : String = "bday-day"
const val bdayMonth : String = "bday-month"
const val bdayYear : String = "bday-year"
const val sex : String = "sex"
const val onETimeCode : String = "one-time-code"
const val organization : String = "organization"
const val ccName : String = "cc-name"
const val ccGivenName : String = "cc-given-name"
const val ccAdditionalName : String = "cc-additional-name"
const val ccFamilyName : String = "cc-family-name"
const val ccNumber : String = "cc-number"
const val ccExp : String = "cc-exp"
const val ccExpMonth : String = "cc-exp-month"
const val ccExpYear : String = "cc-exp-year"
const val ccCsc : String = "cc-csc"
const val ccType : String = "cc-type"
const val transactionCurrency : String = "transaction-currency"
const val transactionAmount : String = "transaction-amount"
const val language : String = "language"
const val url : String = "url"
const val email : String = "email"
const val photo : String = "photo"
const val tel : String = "tel"
const val telCountryCode : String = "tel-country-code"
const val telNational : String = "tel-national"
const val telAreaCode : String = "tel-area-code"
const val telLocal : String = "tel-local"
const val telLocalPrefix : String = "tel-local-prefix"
const val telLocalSuffix : String = "tel-local-suffix"
const val telExtension : String = "tel-extension"
const val impp : String = "impp"

val values : List<String> = listOf("on", "off", "addressLine1", "addressLine2", "addressLine3", "addressLevel1", "addressLevel2", "addressLevel3", "addressLevel4", "streetAddress", "country", "countryName", "postalCode", "name", "additionalName", "familyName", "givenName", "honoricPrefix", "honoricSuffix", "nickname", "organizationTitle", "username", "newPassword", "currentPassword", "bday", "bdayDay", "bdayMonth", "bdayYear", "sex", "onETimeCode", "organization", "ccName", "ccGivenName", "ccAdditionalName", "ccFamilyName", "ccNumber", "ccExp", "ccExpMonth", "ccExpYear", "ccCsc", "ccType", "transactionCurrency", "transactionAmount", "language", "url", "email", "photo", "tel", "telCountryCode", "telNational", "telAreaCode", "telLocal", "telLocalPrefix", "telLocalSuffix", "telExtension", "impp")
}

@Suppress("unused", "EnumEntryName")
enum class InputFormEncType(override val realValue : String) : AttributeEnum {
multipartFormData("multipart/form-data"),
Expand Down
6 changes: 3 additions & 3 deletions src/commonMain/kotlin/generated/gen-tags-i.kt
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ open class INPUT(initialAttributes : Map<String, String>, override val consumer
get() = attributeBooleanTicker[this, "autofocus"]
set(newValue) {attributeBooleanTicker[this, "autofocus"] = newValue}

var autoComplete : Boolean
get() = attributeBooleanBooleanOnOff[this, "autocomplete"]
set(newValue) {attributeBooleanBooleanOnOff[this, "autocomplete"] = newValue}
var autoComplete : String
get() = attributeStringString[this, "autocomplete"]
set(newValue) {attributeStringString[this, "autocomplete"] = newValue}

var checked : Boolean
get() = attributeBooleanTicker[this, "checked"]
Expand Down
13 changes: 8 additions & 5 deletions src/jvmTest/kotlin/streaming.kt
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,11 @@ class TestStreaming {
}

@Test fun `test form with button`() {
assertEquals("<form action=\"/someurl\">" +
"<input type=\"checkbox\" name=\"cb1\">var1" +
assertEquals(
"<form action=\"/someurl\"><input type=\"checkbox\" name=\"cb1\">var1" +
"<input type=\"checkbox\" name=\"cb2\" disabled=\"disabled\">var2" +
"<input type=\"submit\" value=\"Go!\">" +
"</form>",
"<input type=\"text\" name=\"t1\" autocomplete=\"impp\">" +
"<input type=\"submit\" value=\"Go!\"></form>",
StringBuilder().appendHTML(false).form("/someurl") {
checkBoxInput(name = "cb1") {
+"var1"
Expand All @@ -227,6 +227,9 @@ class TestStreaming {
disabled = true
+"var2"
}
textInput(name = "t1") {
autoComplete = InputAutoComplete.impp
}

submitInput {
value = "Go!"
Expand All @@ -240,7 +243,7 @@ class TestStreaming {

val timeSource = TimeSource.Monotonic
val now = timeSource.markNow()
var measuredDuration = Duration.INFINITE
val measuredDuration: Duration

val rs = builder.measureTime(timeSource = timeSource).div {
val measuredStart = timeSource.markNow()
Expand Down

0 comments on commit 363b34e

Please sign in to comment.