From 43ca4ba0234b4e1b8b8a1ca667228276de583730 Mon Sep 17 00:00:00 2001 From: severn-everett Date: Sun, 5 May 2024 12:38:18 +0200 Subject: [PATCH] Add contracts to node append and tag declaration calls (#264) * Added contracts for callbacks passed to DOM elements in JVM * Added contracts for callbacks passed to DOM elements in JS * Added contracts for callbacks passed to DOM elements in WASM-JS * Added contracts for callbacks passed to tag elements * Cleaning up code --- .../main/kotlin/kotlinx/html/generate/main.kt | 54 +- .../kotlin/kotlinx/html/generate/tagsgen.kt | 228 +++-- .../kotlin/generated/gen-consumer-tags.kt | 924 ++++++++++++----- .../kotlin/generated/gen-tag-groups.kt | 177 +++- .../kotlin/generated/gen-tag-unions.kt | 669 ++++++++++--- src/commonMain/kotlin/generated/gen-tags-a.kt | 9 +- src/commonMain/kotlin/generated/gen-tags-b.kt | 3 + src/commonMain/kotlin/generated/gen-tags-c.kt | 9 +- src/commonMain/kotlin/generated/gen-tags-d.kt | 27 +- src/commonMain/kotlin/generated/gen-tags-e.kt | 3 + src/commonMain/kotlin/generated/gen-tags-f.kt | 21 +- src/commonMain/kotlin/generated/gen-tags-h.kt | 51 +- src/commonMain/kotlin/generated/gen-tags-i.kt | 3 + src/commonMain/kotlin/generated/gen-tags-k.kt | 3 + src/commonMain/kotlin/generated/gen-tags-l.kt | 3 + src/commonMain/kotlin/generated/gen-tags-m.kt | 3 + src/commonMain/kotlin/generated/gen-tags-n.kt | 3 + src/commonMain/kotlin/generated/gen-tags-o.kt | 21 +- src/commonMain/kotlin/generated/gen-tags-p.kt | 27 +- src/commonMain/kotlin/generated/gen-tags-q.kt | 3 + src/commonMain/kotlin/generated/gen-tags-r.kt | 15 +- src/commonMain/kotlin/generated/gen-tags-s.kt | 15 +- src/commonMain/kotlin/generated/gen-tags-t.kt | 93 +- src/commonMain/kotlin/generated/gen-tags-u.kt | 9 +- src/commonMain/kotlin/generated/gen-tags-v.kt | 9 +- src/commonTest/kotlin/AttributesTest.kt | 6 +- src/jsMain/kotlin/dom-js.kt | 44 +- .../kotlin/generated/gen-consumer-tags-js.kt | 941 +++++++++++++----- src/jsTest/kotlin/trees.kt | 62 +- src/jvmMain/kotlin/dom-jvm.kt | 80 +- src/jvmTest/kotlin/dom-trees.kt | 46 +- src/wasmJsMain/kotlin/dom-js.kt | 28 +- .../generated/gen-consumer-tags-wasm-js.kt | 940 ++++++++++++----- src/wasmJsTest/kotlin/trees.kt | 27 +- 34 files changed, 3447 insertions(+), 1109 deletions(-) diff --git a/buildSrc/src/main/kotlin/kotlinx/html/generate/main.kt b/buildSrc/src/main/kotlin/kotlinx/html/generate/main.kt index 7d42232b..66d3f30a 100644 --- a/buildSrc/src/main/kotlin/kotlinx/html/generate/main.kt +++ b/buildSrc/src/main/kotlin/kotlinx/html/generate/main.kt @@ -36,16 +36,7 @@ fun generate(pkg: String, todir: String, jsdir: String, wasmJsDir: String) { repository.tags.values.filterIgnored().groupBy { it.name[0] }.entries.forEach { e -> writeIntoFile("$todir/gen-tags-${e.key}.kt") { - packg(pkg) - emptyLine() - import("kotlinx.html.*") - import("kotlinx.html.impl.*") - import("kotlinx.html.attributes.*") - emptyLine() - - doNotEditWarning() - emptyLine() - emptyLine() + fullImportsHeader(pkg) e.value.forEach { tagClass(repository, it, emptySet()) @@ -124,16 +115,7 @@ fun generate(pkg: String, todir: String, jsdir: String, wasmJsDir: String) { FileOutputStream("$todir/gen-tag-unions.kt").writer(Charsets.UTF_8).use { with(it) { - packg(pkg) - emptyLine() - import("kotlinx.html.*") - import("kotlinx.html.impl.*") - import("kotlinx.html.attributes.*") - emptyLine() - - doNotEditWarning() - emptyLine() - emptyLine() + fullImportsHeader(pkg) repository.groupUnions.values.forEach { union -> clazz( @@ -163,16 +145,7 @@ fun generate(pkg: String, todir: String, jsdir: String, wasmJsDir: String) { FileOutputStream("$todir/gen-tag-groups.kt").writer(Charsets.UTF_8).use { with(it) { - packg(pkg) - emptyLine() - import("kotlinx.html.*") - import("kotlinx.html.impl.*") - import("kotlinx.html.attributes.*") - emptyLine() - - doNotEditWarning() - emptyLine() - emptyLine() + fullImportsHeader(pkg) repository.tagGroups.values.forEach { group -> val unions = repository.unionsByGroups[group.name].orEmpty().map { it.name } @@ -319,6 +292,7 @@ private fun generateConsumerTags( emptyLine() packg(pkg) emptyLine() + contractImports() import("kotlinx.html.*") import("kotlinx.html.attributes.*") @@ -379,3 +353,23 @@ private fun Appendable.writeKotlinPoet(builder: FileSpec.Builder.() -> Unit) { .build() .writeTo(this) } + +private fun Appendable.fullImportsHeader(pkg: String) { + packg(pkg) + emptyLine() + contractImports() + import("kotlinx.html.*") + import("kotlinx.html.impl.*") + import("kotlinx.html.attributes.*") + emptyLine() + + doNotEditWarning() + emptyLine() + emptyLine() +} + +private fun Appendable.contractImports() { + import("kotlin.contracts.ExperimentalContracts") + import("kotlin.contracts.InvocationKind") + import("kotlin.contracts.contract") +} diff --git a/buildSrc/src/main/kotlin/kotlinx/html/generate/tagsgen.kt b/buildSrc/src/main/kotlin/kotlinx/html/generate/tagsgen.kt index 7d38d59e..801a5922 100644 --- a/buildSrc/src/main/kotlin/kotlinx/html/generate/tagsgen.kt +++ b/buildSrc/src/main/kotlin/kotlinx/html/generate/tagsgen.kt @@ -12,6 +12,9 @@ import com.squareup.kotlinpoet.TypeVariableName import com.squareup.kotlinpoet.asTypeName import java.util.* +private const val BLOCK_LAMBDA = "block" +private const val CONTENT_LAMBDA = "{+content}" + fun Appendable.tagClass(repository: Repository, tag: TagInfo, excludeAttributes: Set) { val parentAttributeIfaces = tag.attributeGroups.map { it.name.capitalize() + "Facade" } val parentElementIfaces = tag.tagGroupNames.map { it.humanize().capitalize() } @@ -21,24 +24,39 @@ fun Appendable.tagClass(repository: Repository, tag: TagInfo, excludeAttributes: val namespace = tagNamespaces[tag.name.lowercase()] val customizableNamespace = tag.name.lowercase() in tagsWithCustomizableNamespace - val parameters = mutableListOf( - Var("initialAttributes", "Map", false, false, true), - Var("consumer", "TagConsumer<*>", false, true) - ) - val superConstructorArguments = mutableListOf( + val parameters = buildList { + add( + Var( + name = "initialAttributes", + type = "Map", + mutable = false, + override = false, + forceOmitValVar = true + ) + ) + add(Var(name = "consumer", type = "TagConsumer<*>", mutable = false, override = true)) + if (customizableNamespace) { + add( + Var( + name = "namespace", + type = "String?", + mutable = false, + override = false, + forceOmitValVar = true, + defaultValue = namespace?.quote() ?: "null" + ) + ) + } + } + val superConstructorArguments = listOf( tag.name.quote(), "consumer", "initialAttributes", - namespace?.quote().toString(), + if (customizableNamespace) "namespace" else namespace?.quote().toString(), (tag.name in inlineTags).toString(), (tag.name in emptyTags).toString() ) - if (customizableNamespace) { - parameters.add(Var("namespace", "String?", false, false, true, namespace?.quote() ?: "null")) - superConstructorArguments[3] = "namespace" - } - appendLine("@Suppress(\"unused\")") clazz(Clazz( name = tag.className, @@ -49,7 +67,7 @@ fun Appendable.tagClass(repository: Repository, tag: TagInfo, excludeAttributes: } ) + when { allParentIfaces.isNotEmpty() -> listOf(betterParentIfaces).map { renames[it] ?: it } - else -> emptyList() + else -> emptyList() }, isOpen = true )) { @@ -136,16 +154,16 @@ fun Appendable.tagClass(repository: Repository, tag: TagInfo, excludeAttributes: emptyLine() } - tag.directChildren.map { repository.tags[it] }.filterNotNull().filterIgnored().forEach { children -> + tag.directChildren.mapNotNull { repository.tags[it] }.filterIgnored().forEach { children -> htmlTagBuilders(tag.className, children) } if (parentElementIfaces.size > 1) { - val commons = tag.tagGroupNames.map { repository.tagGroups[it]?.tags?.toSet() }.filterNotNull() + val commons = tag.tagGroupNames.mapNotNull { repository.tagGroups[it]?.tags?.toSet() } .reduce { a, b -> a.intersect(b) } if (commons.isNotEmpty()) { parentElementIfaces.forEach { group -> - variable(Var(name = "as" + group, type = group), receiver = tag.className) + variable(Var(name = "as$group", type = group), receiver = tag.className) appendLine() getter() defineIs("this") @@ -183,8 +201,6 @@ internal fun Appendable.tagAttributeVar( return attributeRequest } -fun probeType(htmlClassName: String): Boolean = htmlClassName in knownTagClasses - private fun tagCandidates(tag: TagInfo) = (listOf(tag.memberName) + tagReplacements.map { tag.memberName.replace( it.first.toRegex(), @@ -195,13 +211,7 @@ private fun tagCandidates(tag: TagInfo) = (listOf(tag.memberName) + tagReplaceme fun getTagResultClass(tag: TagInfo): String? = tagCandidates(tag) .map { "HTML${it}Element" } - .firstOrNull { probeType(it) } - -fun contentArgumentValue(tag: TagInfo, blockOrContent: Boolean) = when { - tag.name.lowercase() in emptyTags -> "block" - blockOrContent -> "block" - else -> "{+content}" -} + .firstOrNull { it in knownTagClasses } fun tagConsumerJs(parameter: String): TypeName = ClassName("kotlinx.html", "TagConsumer") @@ -242,6 +252,7 @@ fun consumerBuilderJsPoet( val tagResultClass = getTagResultClass(tag) val cast = if (tagResultClass != null) " as $tagResultClass" else "" val tagClass = ClassName("kotlinx.html", tag.className) + val tagBuilderCouldBeInline = tagBuilderCouldBeInline(tag, blockOrContent) return FunSpec .builder(tag.memberName) .returns(ClassName("org.w3c.dom", tagResultClass ?: defaultTagConsumer)) @@ -249,19 +260,37 @@ fun consumerBuilderJsPoet( .receiver(tagConsumerJs(defaultTagConsumer)) .addKdoc(tag) .addAnnotation(ClassName("kotlinx.html", "HtmlTagMarker")) + .apply { + if (tagBuilderCouldBeInline) { + addAnnotation( + AnnotationSpec.builder(ClassName("", "OptIn")) + .addMember("ExperimentalContracts::class") + .build() + ) + } + } .addTagBuilderFunctionArguments(tag, tagClass, blockOrContent) .apply { - if (tagBuilderCouldBeInline(tag, blockOrContent)) { + if (tagBuilderCouldBeInline) { addModifiers(KModifier.INLINE) + addCode( + """ + |contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + |return %T(${constructorArgs.joinToString(", ")}) + | .visitAndFinalize(this, $BLOCK_LAMBDA) $cast + """.trimMargin(), + tagClass, + ) + } else { + addCode( + """ + |return %T(${constructorArgs.joinToString(", ")}) + | .visitAndFinalize(this, $CONTENT_LAMBDA) $cast + """.trimMargin(), + tagClass, + ) } } - .addCode( - """ - |return %T(${constructorArgs.joinToString(", ")}) - | .visitAndFinalize(this, ${contentArgumentValue(tag, blockOrContent)}) $cast - """.trimMargin(), - tagClass, - ) .build() } @@ -278,6 +307,7 @@ fun consumerBuilderSharedPoet( val tagClass = ClassName("kotlinx.html", tag.className) val typeVariableT = TypeVariableName("T") val typeVariableC = TypeVariableName("C", tagConsumer(typeVariableT)) + val tagBuilderCouldBeInline = tagBuilderCouldBeInline(tag, blockOrContent) return FunSpec .builder(tag.memberName) .returns(typeVariableT) @@ -286,19 +316,37 @@ fun consumerBuilderSharedPoet( .receiver(typeVariableC) .addKdoc(tag) .addAnnotation(ClassName("kotlinx.html", "HtmlTagMarker")) + .apply { + if (tagBuilderCouldBeInline) { + addAnnotation( + AnnotationSpec.builder(ClassName("", "OptIn")) + .addMember("ExperimentalContracts::class") + .build() + ) + } + } .addTagBuilderFunctionArguments(tag, tagClass, blockOrContent) .apply { - if (tagBuilderCouldBeInline(tag, blockOrContent)) { + if (tagBuilderCouldBeInline) { addModifiers(KModifier.INLINE) + addCode( + """ + |contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + |return %T(${constructorArgs.joinToString(", ")}) + | .visitAndFinalize(this, $BLOCK_LAMBDA) + """.trimMargin(), + tagClass, + ) + } else { + addCode( + """ + |return %T(${constructorArgs.joinToString(", ")}) + | .visitAndFinalize(this, $CONTENT_LAMBDA) + """.trimMargin(), + tagClass, + ) } } - .addCode( - """ - |return %T(${constructorArgs.joinToString(", ")}) - | .visitAndFinalize(this, ${contentArgumentValue(tag, blockOrContent)}) - """.trimMargin(), - tagClass, - ) .build() } @@ -311,24 +359,21 @@ private fun FunSpec.Builder.addKdoc(tag: TagInfo): FunSpec.Builder { fun Appendable.htmlTagBuilderMethod(receiver: String, tag: TagInfo, blockOrContent: Boolean) { val arguments = tagBuilderFunctionArguments(tag, blockOrContent) - val constructorArgs = mutableListOf( - buildSuggestedAttributesArgument(tag), - "consumer" - ) - - if (tag.name.lowercase() in tagsWithCustomizableNamespace) { - constructorArgs.add("namespace") + val constructorArgs = buildList { + add(buildSuggestedAttributesArgument(tag)) + add("consumer") + if (tag.name.lowercase() in tagsWithCustomizableNamespace) add("namespace") } tagKdoc(tag) htmlDslMarker() - if (tagBuilderCouldBeInline(tag, blockOrContent)) append("inline ") + val tagBuilderCouldBeInline = tagBuilderCouldBeInline(tag, blockOrContent) + if (tagBuilderCouldBeInline) { + experimentalContractsMarker() + append("inline ") + } function(tag.memberName, arguments, "Unit", receiver = receiver) - defineIs(buildString { - functionCall(tag.className, constructorArgs) - append(".") - functionCall("visit", listOf(contentArgumentValue(tag, blockOrContent))) - }) + tagBody(tagBuilderCouldBeInline, tag, constructorArgs) } fun Appendable.htmlTagEnumBuilderMethod( @@ -345,15 +390,16 @@ fun Appendable.htmlTagEnumBuilderMethod( enumAttribute.enumValues.forEach { enumValue -> val deprecation = findEnumDeprecation(enumAttribute, enumValue) - val constructorArgs = mutableListOf( - buildSuggestedAttributesArgument( - tag, - mapOf(enumAttribute.fieldName to enumAttribute.typeName + "." + enumValue.fieldName + ".realValue") - ), - "consumer" - ) - if (tag.name.lowercase() in tagsWithCustomizableNamespace) { - constructorArgs.add("namespace") + val constructorArgs = buildList { + add( + buildSuggestedAttributesArgument( + tag, + mapOf(enumAttribute.fieldName to enumAttribute.typeName + "." + enumValue.fieldName + ".realValue") + ) + ) + add("consumer") + + if (tag.name.lowercase() in tagsWithCustomizableNamespace) add("namespace") } if (deprecation != null) { @@ -363,13 +409,13 @@ fun Appendable.htmlTagEnumBuilderMethod( indent(indent) htmlDslMarker() - if (tagBuilderCouldBeInline(tag, blockOrContent)) append("inline ") + val tagBuilderCouldBeInline = tagBuilderCouldBeInline(tag, blockOrContent) + if (tagBuilderCouldBeInline) { + experimentalContractsMarker() + append("inline ") + } function(enumValue.fieldName + tag.memberName.capitalize(), arguments, "Unit", receiver = receiver) - defineIs(buildString { - functionCall(tag.className, constructorArgs) - append(".") - functionCall("visit", listOf(contentArgumentValue(tag, blockOrContent))) - }) + tagBody(tagBuilderCouldBeInline, tag, constructorArgs) } } @@ -399,11 +445,8 @@ private fun buildSuggestedAttributesArgument(tag: TagInfo, predefinedValues: Map } } -private fun tagBuilderCouldBeInline(tag: TagInfo, blockOrContent: Boolean): Boolean = when { - tag.name.lowercase() in emptyTags -> true - blockOrContent -> true - else -> false -} +private fun tagBuilderCouldBeInline(tag: TagInfo, blockOrContent: Boolean) = + blockOrContent || tag.name.lowercase() in emptyTags private fun FunSpec.Builder.addTagBuilderFunctionArguments( tag: TagInfo, @@ -472,12 +515,21 @@ private fun tagBuilderFunctionArguments(tag: TagInfo, blockOrContent: Boolean): AttributeType.STRING_SET -> "String" else -> attribute.typeName } - arguments.add(Var(attribute.fieldName, type + "?", defaultValue = "null")) + arguments.add(Var(attribute.fieldName, "$type?", defaultValue = "null")) } fun addNamespaceParameter() { if (customizableNamespace) { - arguments.add(Var("namespace", "String?", false, false, true, defaultNamespace)) + arguments.add( + Var( + name = "namespace", + type = "String?", + mutable = false, + override = false, + forceOmitValVar = true, + defaultValue = defaultNamespace + ) + ) } } @@ -508,6 +560,10 @@ private fun Appendable.htmlDslMarker() { appendLine("@HtmlTagMarker") } +private fun Appendable.experimentalContractsMarker() { + appendLine("@OptIn(ExperimentalContracts::class)") +} + private fun Appendable.tagKdoc(tag: TagInfo) { val kdoc = tag.kdoc ?: return appendLine("/**") @@ -515,6 +571,28 @@ private fun Appendable.tagKdoc(tag: TagInfo) { appendLine(" */") } +private fun Appendable.tagBody(tagBuilderCouldBeInline: Boolean, tag: TagInfo, constructorArgs: List) { + if (tagBuilderCouldBeInline) { + block { + indent() + appendLine("contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }") + indent() + functionCall(tag.className, constructorArgs) + append(".") + functionCall("visit", listOf(BLOCK_LAMBDA)) + appendLine() + } + } else { + defineIs( + buildString { + functionCall(tag.className, constructorArgs) + append(".") + functionCall("visit", listOf(CONTENT_LAMBDA)) + } + ) + } +} + private val inlineTags = """a abbr acronym diff --git a/src/commonMain/kotlin/generated/gen-consumer-tags.kt b/src/commonMain/kotlin/generated/gen-consumer-tags.kt index 909987f3..e60657d4 100644 --- a/src/commonMain/kotlin/generated/gen-consumer-tags.kt +++ b/src/commonMain/kotlin/generated/gen-consumer-tags.kt @@ -4,6 +4,9 @@ *******************************************************************************/ package kotlinx.html +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract import kotlinx.html.* import kotlinx.html.attributes.* @@ -147,126 +150,183 @@ import kotlinx.html.VIDEO * Anchor */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.a( href: String? = null, target: String? = null, classes: String? = null, crossinline block: A.() -> Unit = {}, -): T = A(attributesMapOf("href", href,"target", target,"class", classes), this) - .visitAndFinalize(this, block) +): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return A(attributesMapOf("href", href,"target", target,"class", classes), this) + .visitAndFinalize(this, block) +} /** * Abbreviated form (e.g., WWW, HTTP,etc.) */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.abbr(classes: String? = null, crossinline - block: ABBR.() -> Unit = {}): T = ABBR(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: ABBR.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return ABBR(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Information on author */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.address(classes: String? = null, crossinline - block: ADDRESS.() -> Unit = {}): T = ADDRESS(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: ADDRESS.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return ADDRESS(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Client-side image map area */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.area( shape: AreaShape? = null, alt: String? = null, classes: String? = null, crossinline block: AREA.() -> Unit = {}, -): T = AREA(attributesMapOf("Shape", shape?.enumEncode(),"alt", alt,"class", classes), this) - .visitAndFinalize(this, block) +): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return AREA(attributesMapOf("Shape", shape?.enumEncode(),"alt", alt,"class", classes), this) + .visitAndFinalize(this, block) +} /** * Self-contained syndicatable or reusable composition */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.article(classes: String? = null, crossinline - block: ARTICLE.() -> Unit = {}): T = ARTICLE(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: ARTICLE.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return ARTICLE(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Sidebar for tangentially related content */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.aside(classes: String? = null, crossinline - block: ASIDE.() -> Unit = {}): T = ASIDE(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: ASIDE.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return ASIDE(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Audio player */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.audio(classes: String? = null, crossinline - block: AUDIO.() -> Unit = {}): T = AUDIO(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: AUDIO.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return AUDIO(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Bold text style */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.b(classes: String? = null, crossinline - block: B.() -> Unit = {}): T = B(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: B.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return B(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Document base URI */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.base(classes: String? = null, crossinline - block: BASE.() -> Unit = {}): T = BASE(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: BASE.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return BASE(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Text directionality isolation */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.bdi(classes: String? = null, crossinline - block: BDI.() -> Unit = {}): T = BDI(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: BDI.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return BDI(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * I18N BiDi over-ride */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.bdo(classes: String? = null, crossinline - block: BDO.() -> Unit = {}): T = BDO(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: BDO.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return BDO(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Long quotation */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.blockQuote(classes: String? = null, crossinline - block: BLOCKQUOTE.() -> Unit = {}): T = BLOCKQUOTE(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: BLOCKQUOTE.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return BLOCKQUOTE(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Document body */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.body(classes: String? = null, crossinline - block: BODY.() -> Unit = {}): T = BODY(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: BODY.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return BODY(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Forced line break */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.br(classes: String? = null, crossinline - block: BR.() -> Unit = {}): T = BR(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: BR.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return BR(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Push button */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.button( formEncType: ButtonFormEncType? = null, formMethod: ButtonFormMethod? = null, @@ -274,9 +334,12 @@ public inline fun > C.button( type: ButtonType? = null, classes: String? = null, crossinline block: BUTTON.() -> Unit = {}, -): T = BUTTON(attributesMapOf("formenctype", formEncType?.enumEncode(),"formmethod", - formMethod?.enumEncode(),"name", name,"type", type?.enumEncode(),"class", classes), this) - .visitAndFinalize(this, block) +): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return BUTTON(attributesMapOf("formenctype", formEncType?.enumEncode(),"formmethod", + formMethod?.enumEncode(),"name", name,"type", type?.enumEncode(),"class", classes), this) + .visitAndFinalize(this, block) +} /** * Scriptable bitmap canvas @@ -290,239 +353,355 @@ public fun > C.canvas(classes: String? = null, content: St * Scriptable bitmap canvas */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.canvas(classes: String? = null, crossinline - block: CANVAS.() -> Unit = {}): T = CANVAS(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: CANVAS.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return CANVAS(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Table caption */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.caption(classes: String? = null, crossinline - block: CAPTION.() -> Unit = {}): T = CAPTION(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: CAPTION.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return CAPTION(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Citation */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.cite(classes: String? = null, crossinline - block: CITE.() -> Unit = {}): T = CITE(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: CITE.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return CITE(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Computer code fragment */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.code(classes: String? = null, crossinline - block: CODE.() -> Unit = {}): T = CODE(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: CODE.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return CODE(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Table column */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.col(classes: String? = null, crossinline - block: COL.() -> Unit = {}): T = COL(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: COL.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return COL(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Table column group */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.colGroup(classes: String? = null, crossinline - block: COLGROUP.() -> Unit = {}): T = COLGROUP(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: COLGROUP.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return COLGROUP(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.command( type: CommandType? = null, classes: String? = null, crossinline block: COMMAND.() -> Unit = {}, -): T = COMMAND(attributesMapOf("type", type?.enumEncode(),"class", classes), this) - .visitAndFinalize(this, block) +): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return COMMAND(attributesMapOf("type", type?.enumEncode(),"class", classes), this) + .visitAndFinalize(this, block) +} /** * Container for options for */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.dataList(classes: String? = null, crossinline - block: DATALIST.() -> Unit = {}): T = DATALIST(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: DATALIST.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return DATALIST(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Definition description */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.dd(classes: String? = null, crossinline - block: DD.() -> Unit = {}): T = DD(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: DD.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return DD(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Deleted text */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.del(classes: String? = null, crossinline - block: DEL.() -> Unit = {}): T = DEL(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: DEL.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return DEL(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Disclosure control for hiding details */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.details(classes: String? = null, crossinline - block: DETAILS.() -> Unit = {}): T = DETAILS(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: DETAILS.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return DETAILS(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Instance definition */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.dfn(classes: String? = null, crossinline - block: DFN.() -> Unit = {}): T = DFN(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: DFN.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return DFN(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Dialog box or window */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.dialog(classes: String? = null, crossinline - block: DIALOG.() -> Unit = {}): T = DIALOG(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: DIALOG.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return DIALOG(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Generic language/style container */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.div(classes: String? = null, crossinline - block: DIV.() -> Unit = {}): T = DIV(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: DIV.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return DIV(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Definition list */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.dl(classes: String? = null, crossinline - block: DL.() -> Unit = {}): T = DL(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: DL.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return DL(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Definition term */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.dt(classes: String? = null, crossinline - block: DT.() -> Unit = {}): T = DT(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: DT.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return DT(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Emphasis */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.em(classes: String? = null, crossinline - block: EM.() -> Unit = {}): T = EM(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: EM.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return EM(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Plugin */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.embed(classes: String? = null, crossinline - block: EMBED.() -> Unit = {}): T = EMBED(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: EMBED.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return EMBED(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Form control group */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.fieldSet(classes: String? = null, crossinline - block: FIELDSET.() -> Unit = {}): T = FIELDSET(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: FIELDSET.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return FIELDSET(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Caption for */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.figcaption(classes: String? = null, crossinline - block: FIGCAPTION.() -> Unit = {}): T = FIGCAPTION(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: FIGCAPTION.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return FIGCAPTION(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Figure with optional caption */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.figure(classes: String? = null, crossinline - block: FIGURE.() -> Unit = {}): T = FIGURE(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: FIGURE.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return FIGURE(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Footer for a page or section */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.footer(classes: String? = null, crossinline - block: FOOTER.() -> Unit = {}): T = FOOTER(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: FOOTER.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return FOOTER(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Interactive form */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.form( action: String? = null, encType: FormEncType? = null, method: FormMethod? = null, classes: String? = null, crossinline block: FORM.() -> Unit = {}, -): T = FORM(attributesMapOf("action", action,"enctype", encType?.enumEncode(),"method", - method?.enumEncode(),"class", classes), this) - .visitAndFinalize(this, block) +): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return FORM(attributesMapOf("action", action,"enctype", encType?.enumEncode(),"method", + method?.enumEncode(),"class", classes), this) + .visitAndFinalize(this, block) +} /** * Heading */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.h1(classes: String? = null, crossinline - block: H1.() -> Unit = {}): T = H1(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: H1.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return H1(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Heading */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.h2(classes: String? = null, crossinline - block: H2.() -> Unit = {}): T = H2(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: H2.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return H2(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Heading */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.h3(classes: String? = null, crossinline - block: H3.() -> Unit = {}): T = H3(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: H3.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return H3(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Heading */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.h4(classes: String? = null, crossinline - block: H4.() -> Unit = {}): T = H4(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: H4.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return H4(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Heading */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.h5(classes: String? = null, crossinline - block: H5.() -> Unit = {}): T = H5(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: H5.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return H5(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Heading */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.h6(classes: String? = null, crossinline - block: H6.() -> Unit = {}): T = H6(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: H6.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return H6(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Document head @@ -537,30 +716,45 @@ public fun > C.head(content: String = ""): T = HEAD(emptyM * Document head */ @HtmlTagMarker -public inline fun > C.head(crossinline block: HEAD.() -> Unit = {}): T = - HEAD(emptyMap, this) - .visitAndFinalize(this, block) +@OptIn(ExperimentalContracts::class) +public inline fun > C.head(crossinline block: HEAD.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return HEAD(emptyMap, this) + .visitAndFinalize(this, block) +} /** * Introductory or navigational aids for a page or section */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.`header`(classes: String? = null, crossinline - block: HEADER.() -> Unit = {}): T = HEADER(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: HEADER.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return HEADER(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.hGroup(classes: String? = null, crossinline - block: HGROUP.() -> Unit = {}): T = HGROUP(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: HGROUP.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return HGROUP(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Horizontal rule */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.hr(classes: String? = null, crossinline - block: HR.() -> Unit = {}): T = HR(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: HR.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return HR(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Document root element @@ -576,17 +770,25 @@ public fun > C.html(content: String = "", namespace: Strin * Document root element */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.html(namespace: String? = null, crossinline - block: HTML.() -> Unit = {}): T = HTML(emptyMap, this, namespace) - .visitAndFinalize(this, block) + block: HTML.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return HTML(emptyMap, this, namespace) + .visitAndFinalize(this, block) +} /** * Italic text style */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.i(classes: String? = null, crossinline - block: I.() -> Unit = {}): T = I(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: I.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return I(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Inline subwindow @@ -603,31 +805,40 @@ public fun > C.iframe( * Inline subwindow */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.iframe( sandbox: IframeSandbox? = null, classes: String? = null, crossinline block: IFRAME.() -> Unit = {}, -): T = IFRAME(attributesMapOf("sandbox", sandbox?.enumEncode(),"class", classes), this) - .visitAndFinalize(this, block) +): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return IFRAME(attributesMapOf("sandbox", sandbox?.enumEncode(),"class", classes), this) + .visitAndFinalize(this, block) +} /** * Embedded image */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.img( alt: String? = null, src: String? = null, loading: ImgLoading? = null, classes: String? = null, crossinline block: IMG.() -> Unit = {}, -): T = IMG(attributesMapOf("alt", alt,"src", src,"loading", loading?.enumEncode(),"class", classes), - this) - .visitAndFinalize(this, block) +): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return IMG(attributesMapOf("alt", alt,"src", src,"loading", loading?.enumEncode(),"class", + classes), this) + .visitAndFinalize(this, block) +} /** * Form control */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.input( type: InputType? = null, formEncType: InputFormEncType? = null, @@ -635,105 +846,152 @@ public inline fun > C.input( name: String? = null, classes: String? = null, crossinline block: INPUT.() -> Unit = {}, -): T = INPUT(attributesMapOf("type", type?.enumEncode(),"formenctype", - formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), - this) - .visitAndFinalize(this, block) +): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return INPUT(attributesMapOf("type", type?.enumEncode(),"formenctype", + formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", + classes), this) + .visitAndFinalize(this, block) +} /** * Inserted text */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.ins(classes: String? = null, crossinline - block: INS.() -> Unit = {}): T = INS(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: INS.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return INS(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Text to be entered by the user */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.kbd(classes: String? = null, crossinline - block: KBD.() -> Unit = {}): T = KBD(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: KBD.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return KBD(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Cryptographic key-pair generator form control */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.keyGen( keyType: KeyGenKeyType? = null, classes: String? = null, crossinline block: KEYGEN.() -> Unit = {}, -): T = KEYGEN(attributesMapOf("keytype", keyType?.enumEncode(),"class", classes), this) - .visitAndFinalize(this, block) +): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return KEYGEN(attributesMapOf("keytype", keyType?.enumEncode(),"class", classes), this) + .visitAndFinalize(this, block) +} /** * Form field label text */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.label(classes: String? = null, crossinline - block: LABEL.() -> Unit = {}): T = LABEL(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: LABEL.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return LABEL(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Fieldset legend */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.legend(classes: String? = null, crossinline - block: LEGEND.() -> Unit = {}): T = LEGEND(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: LEGEND.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return LEGEND(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * List item */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.li(classes: String? = null, crossinline - block: LI.() -> Unit = {}): T = LI(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: LI.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return LI(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * A media-independent link */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.link( href: String? = null, rel: String? = null, type: String? = null, crossinline block: LINK.() -> Unit = {}, -): T = LINK(attributesMapOf("href", href,"rel", rel,"type", type), this) - .visitAndFinalize(this, block) +): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return LINK(attributesMapOf("href", href,"rel", rel,"type", type), this) + .visitAndFinalize(this, block) +} /** * Container for the dominant contents of another element */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.main(classes: String? = null, crossinline - block: MAIN.() -> Unit = {}): T = MAIN(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: MAIN.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return MAIN(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Client-side image map */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.map( name: String? = null, classes: String? = null, crossinline block: MAP.() -> Unit = {}, -): T = MAP(attributesMapOf("name", name,"class", classes), this) - .visitAndFinalize(this, block) +): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return MAP(attributesMapOf("name", name,"class", classes), this) + .visitAndFinalize(this, block) +} /** * Highlight */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.mark(classes: String? = null, crossinline - block: MARK.() -> Unit = {}): T = MARK(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: MARK.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return MARK(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.math(classes: String? = null, crossinline - block: MATH.() -> Unit = {}): T = MATH(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: MATH.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return MATH(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} @HtmlTagMarker public fun > C.mathml(classes: String? = null, content: String = ""): T = @@ -741,72 +999,104 @@ public fun > C.mathml(classes: String? = null, content: St .visitAndFinalize(this, {+content}) @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.mathml(classes: String? = null, crossinline - block: MATHML.() -> Unit = {}): T = MATHML(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: MATHML.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return MATHML(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Generic metainformation */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.meta( name: String? = null, content: String? = null, charset: String? = null, crossinline block: META.() -> Unit = {}, -): T = META(attributesMapOf("name", name,"content", content,"charset", charset), this) - .visitAndFinalize(this, block) +): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return META(attributesMapOf("name", name,"content", content,"charset", charset), this) + .visitAndFinalize(this, block) +} /** * Gauge */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.meter(classes: String? = null, crossinline - block: METER.() -> Unit = {}): T = METER(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: METER.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return METER(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Section with navigational links */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.nav(classes: String? = null, crossinline - block: NAV.() -> Unit = {}): T = NAV(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: NAV.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return NAV(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Generic metainformation */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.noScript(classes: String? = null, crossinline - block: NOSCRIPT.() -> Unit = {}): T = NOSCRIPT(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: NOSCRIPT.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return NOSCRIPT(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Generic embedded object */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.htmlObject(classes: String? = null, crossinline - block: OBJECT.() -> Unit = {}): T = OBJECT(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: OBJECT.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return OBJECT(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Ordered list */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.ol(classes: String? = null, crossinline - block: OL.() -> Unit = {}): T = OL(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: OL.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return OL(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Option group */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.optGroup( label: String? = null, classes: String? = null, crossinline block: OPTGROUP.() -> Unit = {}, -): T = OPTGROUP(attributesMapOf("label", label,"class", classes), this) - .visitAndFinalize(this, block) +): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return OPTGROUP(attributesMapOf("label", label,"class", classes), this) + .visitAndFinalize(this, block) +} /** * Selectable choice @@ -820,108 +1110,159 @@ public fun > C.option(classes: String? = null, content: St * Selectable choice */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.option(classes: String? = null, crossinline - block: OPTION.() -> Unit = {}): T = OPTION(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: OPTION.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return OPTION(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Calculated output value */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.output(classes: String? = null, crossinline - block: OUTPUT.() -> Unit = {}): T = OUTPUT(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: OUTPUT.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return OUTPUT(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Paragraph */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.p(classes: String? = null, crossinline - block: P.() -> Unit = {}): T = P(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: P.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return P(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Named property value */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.`param`( name: String? = null, `value`: String? = null, crossinline block: PARAM.() -> Unit = {}, -): T = PARAM(attributesMapOf("name", name,"value", value), this) - .visitAndFinalize(this, block) +): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return PARAM(attributesMapOf("name", name,"value", value), this) + .visitAndFinalize(this, block) +} /** * Pictures container */ @HtmlTagMarker -public inline fun > C.picture(crossinline block: PICTURE.() -> Unit = {}): T = - PICTURE(emptyMap, this) - .visitAndFinalize(this, block) +@OptIn(ExperimentalContracts::class) +public inline fun > C.picture(crossinline block: PICTURE.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return PICTURE(emptyMap, this) + .visitAndFinalize(this, block) +} /** * Preformatted text */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.pre(classes: String? = null, crossinline - block: PRE.() -> Unit = {}): T = PRE(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: PRE.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return PRE(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Progress bar */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.progress(classes: String? = null, crossinline - block: PROGRESS.() -> Unit = {}): T = PROGRESS(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: PROGRESS.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return PROGRESS(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Short inline quotation */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.q(classes: String? = null, crossinline - block: Q.() -> Unit = {}): T = Q(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: Q.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return Q(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Parenthesis for ruby annotation text */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.rp(classes: String? = null, crossinline - block: RP.() -> Unit = {}): T = RP(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: RP.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return RP(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Ruby annotation text */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.rt(classes: String? = null, crossinline - block: RT.() -> Unit = {}): T = RT(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: RT.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return RT(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Ruby annotation(s) */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.ruby(classes: String? = null, crossinline - block: RUBY.() -> Unit = {}): T = RUBY(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: RUBY.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return RUBY(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Strike-through text style */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.s(classes: String? = null, crossinline - block: S.() -> Unit = {}): T = S(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: S.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return S(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Sample or quote text style */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.samp(classes: String? = null, crossinline - block: SAMP.() -> Unit = {}): T = SAMP(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: SAMP.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return SAMP(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Script statements @@ -942,67 +1283,99 @@ public fun > C.script( * Script statements */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.script( type: String? = null, src: String? = null, crossorigin: ScriptCrossorigin? = null, crossinline block: SCRIPT.() -> Unit = {}, -): T = SCRIPT(attributesMapOf("type", type,"src", src,"crossorigin", crossorigin?.enumEncode()), - this) - .visitAndFinalize(this, block) +): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return SCRIPT(attributesMapOf("type", type,"src", src,"crossorigin", crossorigin?.enumEncode()), + this) + .visitAndFinalize(this, block) +} /** * Generic document or application section */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.section(classes: String? = null, crossinline - block: SECTION.() -> Unit = {}): T = SECTION(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: SECTION.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return SECTION(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Option selector */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.select(classes: String? = null, crossinline - block: SELECT.() -> Unit = {}): T = SELECT(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: SELECT.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return SELECT(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.slot(classes: String? = null, crossinline - block: SLOT.() -> Unit = {}): T = SLOT(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: SLOT.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return SLOT(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Small text style */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.small(classes: String? = null, crossinline - block: SMALL.() -> Unit = {}): T = SMALL(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: SMALL.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return SMALL(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Media source for */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.source(classes: String? = null, crossinline - block: SOURCE.() -> Unit = {}): T = SOURCE(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: SOURCE.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return SOURCE(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Generic language/style container */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.span(classes: String? = null, crossinline - block: SPAN.() -> Unit = {}): T = SPAN(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: SPAN.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return SPAN(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Strong emphasis */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.strong(classes: String? = null, crossinline - block: STRONG.() -> Unit = {}): T = STRONG(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: STRONG.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return STRONG(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Style info @@ -1018,33 +1391,49 @@ public fun > C.style(type: String? = null, content: String * Style info */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.style(type: String? = null, crossinline - block: STYLE.() -> Unit = {}): T = STYLE(attributesMapOf("type", type), this) - .visitAndFinalize(this, block) + block: STYLE.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return STYLE(attributesMapOf("type", type), this) + .visitAndFinalize(this, block) +} /** * Subscript */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.sub(classes: String? = null, crossinline - block: SUB.() -> Unit = {}): T = SUB(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: SUB.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return SUB(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Caption for */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.summary(classes: String? = null, crossinline - block: SUMMARY.() -> Unit = {}): T = SUMMARY(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: SUMMARY.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return SUMMARY(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Superscript */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.sup(classes: String? = null, crossinline - block: SUP.() -> Unit = {}): T = SUP(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: SUP.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return SUP(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} @HtmlTagMarker public fun > C.svg(classes: String? = null, content: String = ""): T = @@ -1052,41 +1441,61 @@ public fun > C.svg(classes: String? = null, content: Strin .visitAndFinalize(this, {+content}) @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.svg(classes: String? = null, crossinline - block: SVG.() -> Unit = {}): T = SVG(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: SVG.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return SVG(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.table(classes: String? = null, crossinline - block: TABLE.() -> Unit = {}): T = TABLE(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: TABLE.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return TABLE(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Table body */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.tbody(classes: String? = null, crossinline - block: TBODY.() -> Unit = {}): T = TBODY(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: TBODY.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return TBODY(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Table data cell */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.td(classes: String? = null, crossinline - block: TD.() -> Unit = {}): T = TD(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: TD.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return TD(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Template */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.template(classes: String? = null, crossinline - block: TEMPLATE.() -> Unit = {}): T = TEMPLATE(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: TEMPLATE.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return TEMPLATE(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Multi-line text field @@ -1106,50 +1515,70 @@ public fun > C.textArea( * Multi-line text field */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.textArea( rows: String? = null, cols: String? = null, wrap: TextAreaWrap? = null, classes: String? = null, crossinline block: TEXTAREA.() -> Unit = {}, -): T = TEXTAREA(attributesMapOf("rows", rows,"cols", cols,"wrap", wrap?.enumEncode(),"class", - classes), this) - .visitAndFinalize(this, block) +): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return TEXTAREA(attributesMapOf("rows", rows,"cols", cols,"wrap", wrap?.enumEncode(),"class", + classes), this) + .visitAndFinalize(this, block) +} /** * Table footer */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.tfoot(classes: String? = null, crossinline - block: TFOOT.() -> Unit = {}): T = TFOOT(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: TFOOT.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return TFOOT(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Table header cell */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.th( scope: ThScope? = null, classes: String? = null, crossinline block: TH.() -> Unit = {}, -): T = TH(attributesMapOf("scope", scope?.enumEncode(),"class", classes), this) - .visitAndFinalize(this, block) +): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return TH(attributesMapOf("scope", scope?.enumEncode(),"class", classes), this) + .visitAndFinalize(this, block) +} /** * Table header */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.thead(classes: String? = null, crossinline - block: THEAD.() -> Unit = {}): T = THEAD(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: THEAD.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return THEAD(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Machine-readable equivalent of date- or time-related data */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.time(classes: String? = null, crossinline - block: TIME.() -> Unit = {}): T = TIME(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: TIME.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return TIME(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Document title @@ -1162,46 +1591,69 @@ public fun > C.title(content: String = ""): T = TITLE(empt * Document title */ @HtmlTagMarker -public inline fun > C.title(crossinline block: TITLE.() -> Unit = {}): T = - TITLE(emptyMap, this) - .visitAndFinalize(this, block) +@OptIn(ExperimentalContracts::class) +public inline fun > C.title(crossinline block: TITLE.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return TITLE(emptyMap, this) + .visitAndFinalize(this, block) +} /** * Table row */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.tr(classes: String? = null, crossinline - block: TR.() -> Unit = {}): T = TR(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: TR.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return TR(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Underlined text style */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.u(classes: String? = null, crossinline - block: U.() -> Unit = {}): T = U(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: U.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return U(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Unordered list */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.ul(classes: String? = null, crossinline - block: UL.() -> Unit = {}): T = UL(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: UL.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return UL(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Unordered list */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.htmlVar(classes: String? = null, crossinline - block: VAR.() -> Unit = {}): T = VAR(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: VAR.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return VAR(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Video player */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun > C.video(classes: String? = null, crossinline - block: VIDEO.() -> Unit = {}): T = VIDEO(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: VIDEO.() -> Unit = {}): T { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return VIDEO(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} diff --git a/src/commonMain/kotlin/generated/gen-tag-groups.kt b/src/commonMain/kotlin/generated/gen-tag-groups.kt index 4cb686fb..1be51670 100644 --- a/src/commonMain/kotlin/generated/gen-tag-groups.kt +++ b/src/commonMain/kotlin/generated/gen-tag-groups.kt @@ -1,5 +1,8 @@ package kotlinx.html +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract import kotlinx.html.* import kotlinx.html.impl.* import kotlinx.html.attributes.* @@ -31,146 +34,254 @@ interface SectioningContent : SectioningOrFlowContent, Tag { * Information on author */ @HtmlTagMarker -inline fun FlowContent.address(classes : String? = null, crossinline block : ADDRESS.() -> Unit = {}) : Unit = ADDRESS(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowContent.address(classes : String? = null, crossinline block : ADDRESS.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + ADDRESS(attributesMapOf("class", classes), consumer).visit(block) +} /** * Long quotation */ @HtmlTagMarker -inline fun FlowContent.blockQuote(classes : String? = null, crossinline block : BLOCKQUOTE.() -> Unit = {}) : Unit = BLOCKQUOTE(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowContent.blockQuote(classes : String? = null, crossinline block : BLOCKQUOTE.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + BLOCKQUOTE(attributesMapOf("class", classes), consumer).visit(block) +} /** * Dialog box or window */ @HtmlTagMarker -inline fun FlowContent.dialog(classes : String? = null, crossinline block : DIALOG.() -> Unit = {}) : Unit = DIALOG(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowContent.dialog(classes : String? = null, crossinline block : DIALOG.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + DIALOG(attributesMapOf("class", classes), consumer).visit(block) +} /** * Generic language/style container */ @HtmlTagMarker -inline fun FlowContent.div(classes : String? = null, crossinline block : DIV.() -> Unit = {}) : Unit = DIV(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowContent.div(classes : String? = null, crossinline block : DIV.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + DIV(attributesMapOf("class", classes), consumer).visit(block) +} /** * Definition list */ @HtmlTagMarker -inline fun FlowContent.dl(classes : String? = null, crossinline block : DL.() -> Unit = {}) : Unit = DL(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowContent.dl(classes : String? = null, crossinline block : DL.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + DL(attributesMapOf("class", classes), consumer).visit(block) +} /** * Form control group */ @HtmlTagMarker -inline fun FlowContent.fieldSet(classes : String? = null, crossinline block : FIELDSET.() -> Unit = {}) : Unit = FIELDSET(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowContent.fieldSet(classes : String? = null, crossinline block : FIELDSET.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + FIELDSET(attributesMapOf("class", classes), consumer).visit(block) +} /** * Figure with optional caption */ @HtmlTagMarker -inline fun FlowContent.figure(classes : String? = null, crossinline block : FIGURE.() -> Unit = {}) : Unit = FIGURE(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowContent.figure(classes : String? = null, crossinline block : FIGURE.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + FIGURE(attributesMapOf("class", classes), consumer).visit(block) +} /** * Caption for */ @HtmlTagMarker -inline fun FlowContent.figcaption(classes : String? = null, crossinline block : FIGCAPTION.() -> Unit = {}) : Unit = FIGCAPTION(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowContent.figcaption(classes : String? = null, crossinline block : FIGCAPTION.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + FIGCAPTION(attributesMapOf("class", classes), consumer).visit(block) +} /** * Footer for a page or section */ @HtmlTagMarker -inline fun FlowContent.footer(classes : String? = null, crossinline block : FOOTER.() -> Unit = {}) : Unit = FOOTER(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowContent.footer(classes : String? = null, crossinline block : FOOTER.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + FOOTER(attributesMapOf("class", classes), consumer).visit(block) +} /** * Interactive form */ @HtmlTagMarker -inline fun FlowContent.form(action : String? = null, encType : FormEncType? = null, method : FormMethod? = null, classes : String? = null, crossinline block : FORM.() -> Unit = {}) : Unit = FORM(attributesMapOf("action", action,"enctype", encType?.enumEncode(),"method", method?.enumEncode(),"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowContent.form(action : String? = null, encType : FormEncType? = null, method : FormMethod? = null, classes : String? = null, crossinline block : FORM.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + FORM(attributesMapOf("action", action,"enctype", encType?.enumEncode(),"method", method?.enumEncode(),"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowContent.getForm(action : String? = null, encType : FormEncType? = null, classes : String? = null, crossinline block : FORM.() -> Unit = {}) : Unit = FORM(attributesMapOf("action", action,"enctype", encType?.enumEncode(),"method", FormMethod.get.realValue,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowContent.getForm(action : String? = null, encType : FormEncType? = null, classes : String? = null, crossinline block : FORM.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + FORM(attributesMapOf("action", action,"enctype", encType?.enumEncode(),"method", FormMethod.get.realValue,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowContent.postForm(action : String? = null, encType : FormEncType? = null, classes : String? = null, crossinline block : FORM.() -> Unit = {}) : Unit = FORM(attributesMapOf("action", action,"enctype", encType?.enumEncode(),"method", FormMethod.post.realValue,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowContent.postForm(action : String? = null, encType : FormEncType? = null, classes : String? = null, crossinline block : FORM.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + FORM(attributesMapOf("action", action,"enctype", encType?.enumEncode(),"method", FormMethod.post.realValue,"class", classes), consumer).visit(block) +} @Suppress("DEPRECATION") @HtmlTagMarker -inline fun FlowContent.putForm(action : String? = null, encType : FormEncType? = null, classes : String? = null, crossinline block : FORM.() -> Unit = {}) : Unit = FORM(attributesMapOf("action", action,"enctype", encType?.enumEncode(),"method", FormMethod.put.realValue,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowContent.putForm(action : String? = null, encType : FormEncType? = null, classes : String? = null, crossinline block : FORM.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + FORM(attributesMapOf("action", action,"enctype", encType?.enumEncode(),"method", FormMethod.put.realValue,"class", classes), consumer).visit(block) +} @Suppress("DEPRECATION") @HtmlTagMarker -inline fun FlowContent.deleteForm(action : String? = null, encType : FormEncType? = null, classes : String? = null, crossinline block : FORM.() -> Unit = {}) : Unit = FORM(attributesMapOf("action", action,"enctype", encType?.enumEncode(),"method", FormMethod.delete.realValue,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowContent.deleteForm(action : String? = null, encType : FormEncType? = null, classes : String? = null, crossinline block : FORM.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + FORM(attributesMapOf("action", action,"enctype", encType?.enumEncode(),"method", FormMethod.delete.realValue,"class", classes), consumer).visit(block) +} @Suppress("DEPRECATION") @HtmlTagMarker -inline fun FlowContent.patchForm(action : String? = null, encType : FormEncType? = null, classes : String? = null, crossinline block : FORM.() -> Unit = {}) : Unit = FORM(attributesMapOf("action", action,"enctype", encType?.enumEncode(),"method", FormMethod.patch.realValue,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowContent.patchForm(action : String? = null, encType : FormEncType? = null, classes : String? = null, crossinline block : FORM.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + FORM(attributesMapOf("action", action,"enctype", encType?.enumEncode(),"method", FormMethod.patch.realValue,"class", classes), consumer).visit(block) +} /** * Introductory or navigational aids for a page or section */ @HtmlTagMarker -inline fun FlowContent.header(classes : String? = null, crossinline block : HEADER.() -> Unit = {}) : Unit = HEADER(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowContent.header(classes : String? = null, crossinline block : HEADER.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + HEADER(attributesMapOf("class", classes), consumer).visit(block) +} /** * Horizontal rule */ @HtmlTagMarker -inline fun FlowContent.hr(classes : String? = null, crossinline block : HR.() -> Unit = {}) : Unit = HR(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowContent.hr(classes : String? = null, crossinline block : HR.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + HR(attributesMapOf("class", classes), consumer).visit(block) +} /** * Ordered list */ @HtmlTagMarker -inline fun FlowContent.ol(classes : String? = null, crossinline block : OL.() -> Unit = {}) : Unit = OL(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowContent.ol(classes : String? = null, crossinline block : OL.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + OL(attributesMapOf("class", classes), consumer).visit(block) +} /** * Paragraph */ @HtmlTagMarker -inline fun FlowContent.p(classes : String? = null, crossinline block : P.() -> Unit = {}) : Unit = P(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowContent.p(classes : String? = null, crossinline block : P.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + P(attributesMapOf("class", classes), consumer).visit(block) +} /** * Preformatted text */ @HtmlTagMarker -inline fun FlowContent.pre(classes : String? = null, crossinline block : PRE.() -> Unit = {}) : Unit = PRE(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowContent.pre(classes : String? = null, crossinline block : PRE.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + PRE(attributesMapOf("class", classes), consumer).visit(block) +} /** * Caption for */ @HtmlTagMarker -inline fun FlowContent.summary(classes : String? = null, crossinline block : SUMMARY.() -> Unit = {}) : Unit = SUMMARY(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowContent.summary(classes : String? = null, crossinline block : SUMMARY.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + SUMMARY(attributesMapOf("class", classes), consumer).visit(block) +} /** * */ @HtmlTagMarker -inline fun FlowContent.table(classes : String? = null, crossinline block : TABLE.() -> Unit = {}) : Unit = TABLE(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowContent.table(classes : String? = null, crossinline block : TABLE.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + TABLE(attributesMapOf("class", classes), consumer).visit(block) +} /** * Underlined text style */ @HtmlTagMarker -inline fun FlowContent.u(classes : String? = null, crossinline block : U.() -> Unit = {}) : Unit = U(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowContent.u(classes : String? = null, crossinline block : U.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + U(attributesMapOf("class", classes), consumer).visit(block) +} /** * Unordered list */ @HtmlTagMarker -inline fun FlowContent.ul(classes : String? = null, crossinline block : UL.() -> Unit = {}) : Unit = UL(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowContent.ul(classes : String? = null, crossinline block : UL.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + UL(attributesMapOf("class", classes), consumer).visit(block) +} /** * Strike-through text style */ @HtmlTagMarker -inline fun FlowContent.s(classes : String? = null, crossinline block : S.() -> Unit = {}) : Unit = S(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowContent.s(classes : String? = null, crossinline block : S.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + S(attributesMapOf("class", classes), consumer).visit(block) +} /** * Document base URI */ @HtmlTagMarker -inline fun MetaDataContent.base(classes : String? = null, crossinline block : BASE.() -> Unit = {}) : Unit = BASE(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun MetaDataContent.base(classes : String? = null, crossinline block : BASE.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + BASE(attributesMapOf("class", classes), consumer).visit(block) +} /** * Document title */ @HtmlTagMarker -inline fun MetaDataContent.title(crossinline block : TITLE.() -> Unit = {}) : Unit = TITLE(emptyMap, consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun MetaDataContent.title(crossinline block : TITLE.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + TITLE(emptyMap, consumer).visit(block) +} /** * Document title */ @@ -178,11 +289,19 @@ inline fun MetaDataContent.title(crossinline block : TITLE.() -> Unit = {}) : Un fun MetaDataContent.title(content : String = "") : Unit = TITLE(emptyMap, consumer).visit({+content}) @HtmlTagMarker -inline fun PhrasingContent.slot(classes : String? = null, crossinline block : SLOT.() -> Unit = {}) : Unit = SLOT(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun PhrasingContent.slot(classes : String? = null, crossinline block : SLOT.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + SLOT(attributesMapOf("class", classes), consumer).visit(block) +} /** * Template */ @HtmlTagMarker -inline fun PhrasingContent.template(classes : String? = null, crossinline block : TEMPLATE.() -> Unit = {}) : Unit = TEMPLATE(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun PhrasingContent.template(classes : String? = null, crossinline block : TEMPLATE.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + TEMPLATE(attributesMapOf("class", classes), consumer).visit(block) +} diff --git a/src/commonMain/kotlin/generated/gen-tag-unions.kt b/src/commonMain/kotlin/generated/gen-tag-unions.kt index 620c12f7..3b117df0 100644 --- a/src/commonMain/kotlin/generated/gen-tag-unions.kt +++ b/src/commonMain/kotlin/generated/gen-tag-unions.kt @@ -1,5 +1,8 @@ package kotlinx.html +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract import kotlinx.html.* import kotlinx.html.impl.* import kotlinx.html.attributes.* @@ -33,37 +36,69 @@ interface FlowOrInteractiveOrPhrasingContent : Tag { @HtmlTagMarker -inline fun FlowOrMetaDataOrPhrasingContent.command(type : CommandType? = null, classes : String? = null, crossinline block : COMMAND.() -> Unit = {}) : Unit = COMMAND(attributesMapOf("type", type?.enumEncode(),"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrMetaDataOrPhrasingContent.command(type : CommandType? = null, classes : String? = null, crossinline block : COMMAND.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + COMMAND(attributesMapOf("type", type?.enumEncode(),"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrMetaDataOrPhrasingContent.commandCommand(classes : String? = null, crossinline block : COMMAND.() -> Unit = {}) : Unit = COMMAND(attributesMapOf("type", CommandType.command.realValue,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrMetaDataOrPhrasingContent.commandCommand(classes : String? = null, crossinline block : COMMAND.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + COMMAND(attributesMapOf("type", CommandType.command.realValue,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrMetaDataOrPhrasingContent.checkBoxCommand(classes : String? = null, crossinline block : COMMAND.() -> Unit = {}) : Unit = COMMAND(attributesMapOf("type", CommandType.checkBox.realValue,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrMetaDataOrPhrasingContent.checkBoxCommand(classes : String? = null, crossinline block : COMMAND.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + COMMAND(attributesMapOf("type", CommandType.checkBox.realValue,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrMetaDataOrPhrasingContent.radioCommand(classes : String? = null, crossinline block : COMMAND.() -> Unit = {}) : Unit = COMMAND(attributesMapOf("type", CommandType.radio.realValue,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrMetaDataOrPhrasingContent.radioCommand(classes : String? = null, crossinline block : COMMAND.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + COMMAND(attributesMapOf("type", CommandType.radio.realValue,"class", classes), consumer).visit(block) +} /** * A media-independent link */ @HtmlTagMarker -inline fun FlowOrMetaDataOrPhrasingContent.link(href : String? = null, rel : String? = null, type : String? = null, crossinline block : LINK.() -> Unit = {}) : Unit = LINK(attributesMapOf("href", href,"rel", rel,"type", type), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrMetaDataOrPhrasingContent.link(href : String? = null, rel : String? = null, type : String? = null, crossinline block : LINK.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + LINK(attributesMapOf("href", href,"rel", rel,"type", type), consumer).visit(block) +} /** * Generic metainformation */ @HtmlTagMarker -inline fun FlowOrMetaDataOrPhrasingContent.meta(name : String? = null, content : String? = null, charset : String? = null, crossinline block : META.() -> Unit = {}) : Unit = META(attributesMapOf("name", name,"content", content,"charset", charset), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrMetaDataOrPhrasingContent.meta(name : String? = null, content : String? = null, charset : String? = null, crossinline block : META.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + META(attributesMapOf("name", name,"content", content,"charset", charset), consumer).visit(block) +} /** * Generic metainformation */ @HtmlTagMarker -inline fun FlowOrMetaDataOrPhrasingContent.noScript(classes : String? = null, crossinline block : NOSCRIPT.() -> Unit = {}) : Unit = NOSCRIPT(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrMetaDataOrPhrasingContent.noScript(classes : String? = null, crossinline block : NOSCRIPT.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + NOSCRIPT(attributesMapOf("class", classes), consumer).visit(block) +} /** * Script statements */ @HtmlTagMarker -inline fun FlowOrMetaDataOrPhrasingContent.script(type : String? = null, src : String? = null, crossorigin : ScriptCrossorigin? = null, crossinline block : SCRIPT.() -> Unit = {}) : Unit = SCRIPT(attributesMapOf("type", type,"src", src,"crossorigin", crossorigin?.enumEncode()), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrMetaDataOrPhrasingContent.script(type : String? = null, src : String? = null, crossorigin : ScriptCrossorigin? = null, crossinline block : SCRIPT.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + SCRIPT(attributesMapOf("type", type,"src", src,"crossorigin", crossorigin?.enumEncode()), consumer).visit(block) +} @Deprecated("This tag doesn't support content or requires unsafe (try unsafe {})") @Suppress("DEPRECATION") /** @@ -72,9 +107,17 @@ inline fun FlowOrMetaDataOrPhrasingContent.script(type : String? = null, src : S @HtmlTagMarker fun FlowOrMetaDataOrPhrasingContent.script(type : String? = null, src : String? = null, crossorigin : ScriptCrossorigin? = null, content : String = "") : Unit = SCRIPT(attributesMapOf("type", type,"src", src,"crossorigin", crossorigin?.enumEncode()), consumer).visit({+content}) @HtmlTagMarker -inline fun FlowOrMetaDataOrPhrasingContent.anonymousScript(type : String? = null, src : String? = null, crossinline block : SCRIPT.() -> Unit = {}) : Unit = SCRIPT(attributesMapOf("type", type,"src", src,"crossorigin", ScriptCrossorigin.anonymous.realValue), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrMetaDataOrPhrasingContent.anonymousScript(type : String? = null, src : String? = null, crossinline block : SCRIPT.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + SCRIPT(attributesMapOf("type", type,"src", src,"crossorigin", ScriptCrossorigin.anonymous.realValue), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrMetaDataOrPhrasingContent.useCredentialsScript(type : String? = null, src : String? = null, crossinline block : SCRIPT.() -> Unit = {}) : Unit = SCRIPT(attributesMapOf("type", type,"src", src,"crossorigin", ScriptCrossorigin.useCredentials.realValue), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrMetaDataOrPhrasingContent.useCredentialsScript(type : String? = null, src : String? = null, crossinline block : SCRIPT.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + SCRIPT(attributesMapOf("type", type,"src", src,"crossorigin", ScriptCrossorigin.useCredentials.realValue), consumer).visit(block) +} @Deprecated("This tag doesn't support content or requires unsafe (try unsafe {})") @Suppress("DEPRECATION") @HtmlTagMarker @@ -87,47 +130,79 @@ fun FlowOrMetaDataOrPhrasingContent.useCredentialsScript(type : String? = null, * Heading */ @HtmlTagMarker -inline fun FlowOrHeadingContent.h1(classes : String? = null, crossinline block : H1.() -> Unit = {}) : Unit = H1(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrHeadingContent.h1(classes : String? = null, crossinline block : H1.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + H1(attributesMapOf("class", classes), consumer).visit(block) +} /** * Heading */ @HtmlTagMarker -inline fun FlowOrHeadingContent.h2(classes : String? = null, crossinline block : H2.() -> Unit = {}) : Unit = H2(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrHeadingContent.h2(classes : String? = null, crossinline block : H2.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + H2(attributesMapOf("class", classes), consumer).visit(block) +} /** * Heading */ @HtmlTagMarker -inline fun FlowOrHeadingContent.h3(classes : String? = null, crossinline block : H3.() -> Unit = {}) : Unit = H3(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrHeadingContent.h3(classes : String? = null, crossinline block : H3.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + H3(attributesMapOf("class", classes), consumer).visit(block) +} /** * Heading */ @HtmlTagMarker -inline fun FlowOrHeadingContent.h4(classes : String? = null, crossinline block : H4.() -> Unit = {}) : Unit = H4(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrHeadingContent.h4(classes : String? = null, crossinline block : H4.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + H4(attributesMapOf("class", classes), consumer).visit(block) +} /** * Heading */ @HtmlTagMarker -inline fun FlowOrHeadingContent.h5(classes : String? = null, crossinline block : H5.() -> Unit = {}) : Unit = H5(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrHeadingContent.h5(classes : String? = null, crossinline block : H5.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + H5(attributesMapOf("class", classes), consumer).visit(block) +} /** * Heading */ @HtmlTagMarker -inline fun FlowOrHeadingContent.h6(classes : String? = null, crossinline block : H6.() -> Unit = {}) : Unit = H6(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrHeadingContent.h6(classes : String? = null, crossinline block : H6.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + H6(attributesMapOf("class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrHeadingContent.hGroup(classes : String? = null, crossinline block : HGROUP.() -> Unit = {}) : Unit = HGROUP(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrHeadingContent.hGroup(classes : String? = null, crossinline block : HGROUP.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + HGROUP(attributesMapOf("class", classes), consumer).visit(block) +} /** * Style info */ @HtmlTagMarker -inline fun FlowOrMetaDataContent.style(type : String? = null, crossinline block : STYLE.() -> Unit = {}) : Unit = STYLE(attributesMapOf("type", type), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrMetaDataContent.style(type : String? = null, crossinline block : STYLE.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + STYLE(attributesMapOf("type", type), consumer).visit(block) +} @Deprecated("This tag doesn't support content or requires unsafe (try unsafe {})") @Suppress("DEPRECATION") /** @@ -141,58 +216,106 @@ fun FlowOrMetaDataContent.style(type : String? = null, content : String = "") : * Disclosure control for hiding details */ @HtmlTagMarker -inline fun FlowOrInteractiveContent.details(classes : String? = null, crossinline block : DETAILS.() -> Unit = {}) : Unit = DETAILS(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveContent.details(classes : String? = null, crossinline block : DETAILS.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + DETAILS(attributesMapOf("class", classes), consumer).visit(block) +} /** * Abbreviated form (e.g., WWW, HTTP,etc.) */ @HtmlTagMarker -inline fun FlowOrPhrasingContent.abbr(classes : String? = null, crossinline block : ABBR.() -> Unit = {}) : Unit = ABBR(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.abbr(classes : String? = null, crossinline block : ABBR.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + ABBR(attributesMapOf("class", classes), consumer).visit(block) +} /** * Client-side image map area */ @HtmlTagMarker -inline fun FlowOrPhrasingContent.area(shape : AreaShape? = null, alt : String? = null, classes : String? = null, crossinline block : AREA.() -> Unit = {}) : Unit = AREA(attributesMapOf("Shape", shape?.enumEncode(),"alt", alt,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.area(shape : AreaShape? = null, alt : String? = null, classes : String? = null, crossinline block : AREA.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + AREA(attributesMapOf("Shape", shape?.enumEncode(),"alt", alt,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrPhrasingContent.rectArea(alt : String? = null, classes : String? = null, crossinline block : AREA.() -> Unit = {}) : Unit = AREA(attributesMapOf("Shape", AreaShape.rect.realValue,"alt", alt,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.rectArea(alt : String? = null, classes : String? = null, crossinline block : AREA.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + AREA(attributesMapOf("Shape", AreaShape.rect.realValue,"alt", alt,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrPhrasingContent.circleArea(alt : String? = null, classes : String? = null, crossinline block : AREA.() -> Unit = {}) : Unit = AREA(attributesMapOf("Shape", AreaShape.circle.realValue,"alt", alt,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.circleArea(alt : String? = null, classes : String? = null, crossinline block : AREA.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + AREA(attributesMapOf("Shape", AreaShape.circle.realValue,"alt", alt,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrPhrasingContent.polyArea(alt : String? = null, classes : String? = null, crossinline block : AREA.() -> Unit = {}) : Unit = AREA(attributesMapOf("Shape", AreaShape.poly.realValue,"alt", alt,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.polyArea(alt : String? = null, classes : String? = null, crossinline block : AREA.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + AREA(attributesMapOf("Shape", AreaShape.poly.realValue,"alt", alt,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrPhrasingContent.defaultArea(alt : String? = null, classes : String? = null, crossinline block : AREA.() -> Unit = {}) : Unit = AREA(attributesMapOf("Shape", AreaShape.default.realValue,"alt", alt,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.defaultArea(alt : String? = null, classes : String? = null, crossinline block : AREA.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + AREA(attributesMapOf("Shape", AreaShape.default.realValue,"alt", alt,"class", classes), consumer).visit(block) +} /** * Bold text style */ @HtmlTagMarker -inline fun FlowOrPhrasingContent.b(classes : String? = null, crossinline block : B.() -> Unit = {}) : Unit = B(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.b(classes : String? = null, crossinline block : B.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + B(attributesMapOf("class", classes), consumer).visit(block) +} /** * Text directionality isolation */ @HtmlTagMarker -inline fun FlowOrPhrasingContent.bdi(classes : String? = null, crossinline block : BDI.() -> Unit = {}) : Unit = BDI(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.bdi(classes : String? = null, crossinline block : BDI.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + BDI(attributesMapOf("class", classes), consumer).visit(block) +} /** * I18N BiDi over-ride */ @HtmlTagMarker -inline fun FlowOrPhrasingContent.bdo(classes : String? = null, crossinline block : BDO.() -> Unit = {}) : Unit = BDO(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.bdo(classes : String? = null, crossinline block : BDO.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + BDO(attributesMapOf("class", classes), consumer).visit(block) +} /** * Forced line break */ @HtmlTagMarker -inline fun FlowOrPhrasingContent.br(classes : String? = null, crossinline block : BR.() -> Unit = {}) : Unit = BR(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.br(classes : String? = null, crossinline block : BR.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + BR(attributesMapOf("class", classes), consumer).visit(block) +} /** * Scriptable bitmap canvas */ @HtmlTagMarker -inline fun FlowOrPhrasingContent.canvas(classes : String? = null, crossinline block : CANVAS.() -> Unit = {}) : Unit = CANVAS(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.canvas(classes : String? = null, crossinline block : CANVAS.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + CANVAS(attributesMapOf("class", classes), consumer).visit(block) +} /** * Scriptable bitmap canvas */ @@ -203,139 +326,235 @@ fun FlowOrPhrasingContent.canvas(classes : String? = null, content : String = "" * Citation */ @HtmlTagMarker -inline fun FlowOrPhrasingContent.cite(classes : String? = null, crossinline block : CITE.() -> Unit = {}) : Unit = CITE(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.cite(classes : String? = null, crossinline block : CITE.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + CITE(attributesMapOf("class", classes), consumer).visit(block) +} /** * Computer code fragment */ @HtmlTagMarker -inline fun FlowOrPhrasingContent.code(classes : String? = null, crossinline block : CODE.() -> Unit = {}) : Unit = CODE(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.code(classes : String? = null, crossinline block : CODE.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + CODE(attributesMapOf("class", classes), consumer).visit(block) +} /** * Container for options for */ @HtmlTagMarker -inline fun FlowOrPhrasingContent.dataList(classes : String? = null, crossinline block : DATALIST.() -> Unit = {}) : Unit = DATALIST(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.dataList(classes : String? = null, crossinline block : DATALIST.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + DATALIST(attributesMapOf("class", classes), consumer).visit(block) +} /** * Deleted text */ @HtmlTagMarker -inline fun FlowOrPhrasingContent.del(classes : String? = null, crossinline block : DEL.() -> Unit = {}) : Unit = DEL(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.del(classes : String? = null, crossinline block : DEL.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + DEL(attributesMapOf("class", classes), consumer).visit(block) +} /** * Instance definition */ @HtmlTagMarker -inline fun FlowOrPhrasingContent.dfn(classes : String? = null, crossinline block : DFN.() -> Unit = {}) : Unit = DFN(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.dfn(classes : String? = null, crossinline block : DFN.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + DFN(attributesMapOf("class", classes), consumer).visit(block) +} /** * Emphasis */ @HtmlTagMarker -inline fun FlowOrPhrasingContent.em(classes : String? = null, crossinline block : EM.() -> Unit = {}) : Unit = EM(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.em(classes : String? = null, crossinline block : EM.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + EM(attributesMapOf("class", classes), consumer).visit(block) +} /** * Italic text style */ @HtmlTagMarker -inline fun FlowOrPhrasingContent.i(classes : String? = null, crossinline block : I.() -> Unit = {}) : Unit = I(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.i(classes : String? = null, crossinline block : I.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + I(attributesMapOf("class", classes), consumer).visit(block) +} /** * Inserted text */ @HtmlTagMarker -inline fun FlowOrPhrasingContent.ins(classes : String? = null, crossinline block : INS.() -> Unit = {}) : Unit = INS(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.ins(classes : String? = null, crossinline block : INS.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + INS(attributesMapOf("class", classes), consumer).visit(block) +} /** * Text to be entered by the user */ @HtmlTagMarker -inline fun FlowOrPhrasingContent.kbd(classes : String? = null, crossinline block : KBD.() -> Unit = {}) : Unit = KBD(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.kbd(classes : String? = null, crossinline block : KBD.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + KBD(attributesMapOf("class", classes), consumer).visit(block) +} /** * Client-side image map */ @HtmlTagMarker -inline fun FlowOrPhrasingContent.map(name : String? = null, classes : String? = null, crossinline block : MAP.() -> Unit = {}) : Unit = MAP(attributesMapOf("name", name,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.map(name : String? = null, classes : String? = null, crossinline block : MAP.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + MAP(attributesMapOf("name", name,"class", classes), consumer).visit(block) +} /** * Highlight */ @HtmlTagMarker -inline fun FlowOrPhrasingContent.mark(classes : String? = null, crossinline block : MARK.() -> Unit = {}) : Unit = MARK(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.mark(classes : String? = null, crossinline block : MARK.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + MARK(attributesMapOf("class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrPhrasingContent.math(classes : String? = null, crossinline block : MATH.() -> Unit = {}) : Unit = MATH(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.math(classes : String? = null, crossinline block : MATH.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + MATH(attributesMapOf("class", classes), consumer).visit(block) +} /** * Gauge */ @HtmlTagMarker -inline fun FlowOrPhrasingContent.meter(classes : String? = null, crossinline block : METER.() -> Unit = {}) : Unit = METER(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.meter(classes : String? = null, crossinline block : METER.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + METER(attributesMapOf("class", classes), consumer).visit(block) +} /** * Calculated output value */ @HtmlTagMarker -inline fun FlowOrPhrasingContent.output(classes : String? = null, crossinline block : OUTPUT.() -> Unit = {}) : Unit = OUTPUT(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.output(classes : String? = null, crossinline block : OUTPUT.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + OUTPUT(attributesMapOf("class", classes), consumer).visit(block) +} /** * Progress bar */ @HtmlTagMarker -inline fun FlowOrPhrasingContent.progress(classes : String? = null, crossinline block : PROGRESS.() -> Unit = {}) : Unit = PROGRESS(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.progress(classes : String? = null, crossinline block : PROGRESS.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + PROGRESS(attributesMapOf("class", classes), consumer).visit(block) +} /** * Short inline quotation */ @HtmlTagMarker -inline fun FlowOrPhrasingContent.q(classes : String? = null, crossinline block : Q.() -> Unit = {}) : Unit = Q(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.q(classes : String? = null, crossinline block : Q.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + Q(attributesMapOf("class", classes), consumer).visit(block) +} /** * Ruby annotation(s) */ @HtmlTagMarker -inline fun FlowOrPhrasingContent.ruby(classes : String? = null, crossinline block : RUBY.() -> Unit = {}) : Unit = RUBY(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.ruby(classes : String? = null, crossinline block : RUBY.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + RUBY(attributesMapOf("class", classes), consumer).visit(block) +} /** * Sample or quote text style */ @HtmlTagMarker -inline fun FlowOrPhrasingContent.samp(classes : String? = null, crossinline block : SAMP.() -> Unit = {}) : Unit = SAMP(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.samp(classes : String? = null, crossinline block : SAMP.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + SAMP(attributesMapOf("class", classes), consumer).visit(block) +} /** * Small text style */ @HtmlTagMarker -inline fun FlowOrPhrasingContent.small(classes : String? = null, crossinline block : SMALL.() -> Unit = {}) : Unit = SMALL(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.small(classes : String? = null, crossinline block : SMALL.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + SMALL(attributesMapOf("class", classes), consumer).visit(block) +} /** * Generic language/style container */ @HtmlTagMarker -inline fun FlowOrPhrasingContent.span(classes : String? = null, crossinline block : SPAN.() -> Unit = {}) : Unit = SPAN(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.span(classes : String? = null, crossinline block : SPAN.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + SPAN(attributesMapOf("class", classes), consumer).visit(block) +} /** * Strong emphasis */ @HtmlTagMarker -inline fun FlowOrPhrasingContent.strong(classes : String? = null, crossinline block : STRONG.() -> Unit = {}) : Unit = STRONG(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.strong(classes : String? = null, crossinline block : STRONG.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + STRONG(attributesMapOf("class", classes), consumer).visit(block) +} /** * Subscript */ @HtmlTagMarker -inline fun FlowOrPhrasingContent.sub(classes : String? = null, crossinline block : SUB.() -> Unit = {}) : Unit = SUB(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.sub(classes : String? = null, crossinline block : SUB.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + SUB(attributesMapOf("class", classes), consumer).visit(block) +} /** * Superscript */ @HtmlTagMarker -inline fun FlowOrPhrasingContent.sup(classes : String? = null, crossinline block : SUP.() -> Unit = {}) : Unit = SUP(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.sup(classes : String? = null, crossinline block : SUP.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + SUP(attributesMapOf("class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrPhrasingContent.svg(classes : String? = null, crossinline block : SVG.() -> Unit = {}) : Unit = SVG(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.svg(classes : String? = null, crossinline block : SVG.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + SVG(attributesMapOf("class", classes), consumer).visit(block) +} @HtmlTagMarker fun FlowOrPhrasingContent.svg(classes : String? = null, content : String = "") : Unit = SVG(attributesMapOf("class", classes), consumer).visit({+content}) @@ -343,99 +562,179 @@ fun FlowOrPhrasingContent.svg(classes : String? = null, content : String = "") : * Machine-readable equivalent of date- or time-related data */ @HtmlTagMarker -inline fun FlowOrPhrasingContent.time(classes : String? = null, crossinline block : TIME.() -> Unit = {}) : Unit = TIME(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.time(classes : String? = null, crossinline block : TIME.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + TIME(attributesMapOf("class", classes), consumer).visit(block) +} /** * Unordered list */ @HtmlTagMarker -inline fun FlowOrPhrasingContent.htmlVar(classes : String? = null, crossinline block : VAR.() -> Unit = {}) : Unit = VAR(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrPhrasingContent.htmlVar(classes : String? = null, crossinline block : VAR.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + VAR(attributesMapOf("class", classes), consumer).visit(block) +} /** * Self-contained syndicatable or reusable composition */ @HtmlTagMarker -inline fun SectioningOrFlowContent.article(classes : String? = null, crossinline block : ARTICLE.() -> Unit = {}) : Unit = ARTICLE(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun SectioningOrFlowContent.article(classes : String? = null, crossinline block : ARTICLE.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + ARTICLE(attributesMapOf("class", classes), consumer).visit(block) +} /** * Sidebar for tangentially related content */ @HtmlTagMarker -inline fun SectioningOrFlowContent.aside(classes : String? = null, crossinline block : ASIDE.() -> Unit = {}) : Unit = ASIDE(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun SectioningOrFlowContent.aside(classes : String? = null, crossinline block : ASIDE.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + ASIDE(attributesMapOf("class", classes), consumer).visit(block) +} /** * Container for the dominant contents of another element */ @HtmlTagMarker -inline fun SectioningOrFlowContent.main(classes : String? = null, crossinline block : MAIN.() -> Unit = {}) : Unit = MAIN(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun SectioningOrFlowContent.main(classes : String? = null, crossinline block : MAIN.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + MAIN(attributesMapOf("class", classes), consumer).visit(block) +} /** * Section with navigational links */ @HtmlTagMarker -inline fun SectioningOrFlowContent.nav(classes : String? = null, crossinline block : NAV.() -> Unit = {}) : Unit = NAV(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun SectioningOrFlowContent.nav(classes : String? = null, crossinline block : NAV.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + NAV(attributesMapOf("class", classes), consumer).visit(block) +} /** * Generic document or application section */ @HtmlTagMarker -inline fun SectioningOrFlowContent.section(classes : String? = null, crossinline block : SECTION.() -> Unit = {}) : Unit = SECTION(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun SectioningOrFlowContent.section(classes : String? = null, crossinline block : SECTION.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + SECTION(attributesMapOf("class", classes), consumer).visit(block) +} /** * Anchor */ @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.a(href : String? = null, target : String? = null, classes : String? = null, crossinline block : A.() -> Unit = {}) : Unit = A(attributesMapOf("href", href,"target", target,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.a(href : String? = null, target : String? = null, classes : String? = null, crossinline block : A.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + A(attributesMapOf("href", href,"target", target,"class", classes), consumer).visit(block) +} /** * Audio player */ @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.audio(classes : String? = null, crossinline block : AUDIO.() -> Unit = {}) : Unit = AUDIO(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.audio(classes : String? = null, crossinline block : AUDIO.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + AUDIO(attributesMapOf("class", classes), consumer).visit(block) +} /** * Push button */ @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.button(formEncType : ButtonFormEncType? = null, formMethod : ButtonFormMethod? = null, name : String? = null, type : ButtonType? = null, classes : String? = null, crossinline block : BUTTON.() -> Unit = {}) : Unit = BUTTON(attributesMapOf("formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"type", type?.enumEncode(),"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.button(formEncType : ButtonFormEncType? = null, formMethod : ButtonFormMethod? = null, name : String? = null, type : ButtonType? = null, classes : String? = null, crossinline block : BUTTON.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + BUTTON(attributesMapOf("formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"type", type?.enumEncode(),"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.getButton(formEncType : ButtonFormEncType? = null, name : String? = null, type : ButtonType? = null, classes : String? = null, crossinline block : BUTTON.() -> Unit = {}) : Unit = BUTTON(attributesMapOf("formenctype", formEncType?.enumEncode(),"formmethod", ButtonFormMethod.get.realValue,"name", name,"type", type?.enumEncode(),"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.getButton(formEncType : ButtonFormEncType? = null, name : String? = null, type : ButtonType? = null, classes : String? = null, crossinline block : BUTTON.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + BUTTON(attributesMapOf("formenctype", formEncType?.enumEncode(),"formmethod", ButtonFormMethod.get.realValue,"name", name,"type", type?.enumEncode(),"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.postButton(formEncType : ButtonFormEncType? = null, name : String? = null, type : ButtonType? = null, classes : String? = null, crossinline block : BUTTON.() -> Unit = {}) : Unit = BUTTON(attributesMapOf("formenctype", formEncType?.enumEncode(),"formmethod", ButtonFormMethod.post.realValue,"name", name,"type", type?.enumEncode(),"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.postButton(formEncType : ButtonFormEncType? = null, name : String? = null, type : ButtonType? = null, classes : String? = null, crossinline block : BUTTON.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + BUTTON(attributesMapOf("formenctype", formEncType?.enumEncode(),"formmethod", ButtonFormMethod.post.realValue,"name", name,"type", type?.enumEncode(),"class", classes), consumer).visit(block) +} @Suppress("DEPRECATION") @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.putButton(formEncType : ButtonFormEncType? = null, name : String? = null, type : ButtonType? = null, classes : String? = null, crossinline block : BUTTON.() -> Unit = {}) : Unit = BUTTON(attributesMapOf("formenctype", formEncType?.enumEncode(),"formmethod", ButtonFormMethod.put.realValue,"name", name,"type", type?.enumEncode(),"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.putButton(formEncType : ButtonFormEncType? = null, name : String? = null, type : ButtonType? = null, classes : String? = null, crossinline block : BUTTON.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + BUTTON(attributesMapOf("formenctype", formEncType?.enumEncode(),"formmethod", ButtonFormMethod.put.realValue,"name", name,"type", type?.enumEncode(),"class", classes), consumer).visit(block) +} @Suppress("DEPRECATION") @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.deleteButton(formEncType : ButtonFormEncType? = null, name : String? = null, type : ButtonType? = null, classes : String? = null, crossinline block : BUTTON.() -> Unit = {}) : Unit = BUTTON(attributesMapOf("formenctype", formEncType?.enumEncode(),"formmethod", ButtonFormMethod.delete.realValue,"name", name,"type", type?.enumEncode(),"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.deleteButton(formEncType : ButtonFormEncType? = null, name : String? = null, type : ButtonType? = null, classes : String? = null, crossinline block : BUTTON.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + BUTTON(attributesMapOf("formenctype", formEncType?.enumEncode(),"formmethod", ButtonFormMethod.delete.realValue,"name", name,"type", type?.enumEncode(),"class", classes), consumer).visit(block) +} @Suppress("DEPRECATION") @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.patchButton(formEncType : ButtonFormEncType? = null, name : String? = null, type : ButtonType? = null, classes : String? = null, crossinline block : BUTTON.() -> Unit = {}) : Unit = BUTTON(attributesMapOf("formenctype", formEncType?.enumEncode(),"formmethod", ButtonFormMethod.patch.realValue,"name", name,"type", type?.enumEncode(),"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.patchButton(formEncType : ButtonFormEncType? = null, name : String? = null, type : ButtonType? = null, classes : String? = null, crossinline block : BUTTON.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + BUTTON(attributesMapOf("formenctype", formEncType?.enumEncode(),"formmethod", ButtonFormMethod.patch.realValue,"name", name,"type", type?.enumEncode(),"class", classes), consumer).visit(block) +} /** * Plugin */ @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.embed(classes : String? = null, crossinline block : EMBED.() -> Unit = {}) : Unit = EMBED(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.embed(classes : String? = null, crossinline block : EMBED.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + EMBED(attributesMapOf("class", classes), consumer).visit(block) +} /** * Inline subwindow */ @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.iframe(sandbox : IframeSandbox? = null, classes : String? = null, crossinline block : IFRAME.() -> Unit = {}) : Unit = IFRAME(attributesMapOf("sandbox", sandbox?.enumEncode(),"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.iframe(sandbox : IframeSandbox? = null, classes : String? = null, crossinline block : IFRAME.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + IFRAME(attributesMapOf("sandbox", sandbox?.enumEncode(),"class", classes), consumer).visit(block) +} /** * Inline subwindow */ @HtmlTagMarker fun FlowOrInteractiveOrPhrasingContent.iframe(sandbox : IframeSandbox? = null, classes : String? = null, content : String = "") : Unit = IFRAME(attributesMapOf("sandbox", sandbox?.enumEncode(),"class", classes), consumer).visit({+content}) @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.allowSameOriginIframe(classes : String? = null, crossinline block : IFRAME.() -> Unit = {}) : Unit = IFRAME(attributesMapOf("sandbox", IframeSandbox.allowSameOrigin.realValue,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.allowSameOriginIframe(classes : String? = null, crossinline block : IFRAME.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + IFRAME(attributesMapOf("sandbox", IframeSandbox.allowSameOrigin.realValue,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.allowFormSIframe(classes : String? = null, crossinline block : IFRAME.() -> Unit = {}) : Unit = IFRAME(attributesMapOf("sandbox", IframeSandbox.allowFormS.realValue,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.allowFormSIframe(classes : String? = null, crossinline block : IFRAME.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + IFRAME(attributesMapOf("sandbox", IframeSandbox.allowFormS.realValue,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.allowScriptsIframe(classes : String? = null, crossinline block : IFRAME.() -> Unit = {}) : Unit = IFRAME(attributesMapOf("sandbox", IframeSandbox.allowScripts.realValue,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.allowScriptsIframe(classes : String? = null, crossinline block : IFRAME.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + IFRAME(attributesMapOf("sandbox", IframeSandbox.allowScripts.realValue,"class", classes), consumer).visit(block) +} @HtmlTagMarker fun FlowOrInteractiveOrPhrasingContent.allowSameOriginIframe(classes : String? = null, content : String = "") : Unit = IFRAME(attributesMapOf("sandbox", IframeSandbox.allowSameOrigin.realValue,"class", classes), consumer).visit({+content}) @HtmlTagMarker @@ -447,110 +746,254 @@ fun FlowOrInteractiveOrPhrasingContent.allowScriptsIframe(classes : String? = nu * Embedded image */ @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.img(alt : String? = null, src : String? = null, loading : ImgLoading? = null, classes : String? = null, crossinline block : IMG.() -> Unit = {}) : Unit = IMG(attributesMapOf("alt", alt,"src", src,"loading", loading?.enumEncode(),"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.img(alt : String? = null, src : String? = null, loading : ImgLoading? = null, classes : String? = null, crossinline block : IMG.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + IMG(attributesMapOf("alt", alt,"src", src,"loading", loading?.enumEncode(),"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.eagerImg(alt : String? = null, src : String? = null, classes : String? = null, crossinline block : IMG.() -> Unit = {}) : Unit = IMG(attributesMapOf("alt", alt,"src", src,"loading", ImgLoading.eager.realValue,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.eagerImg(alt : String? = null, src : String? = null, classes : String? = null, crossinline block : IMG.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + IMG(attributesMapOf("alt", alt,"src", src,"loading", ImgLoading.eager.realValue,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.lazyImg(alt : String? = null, src : String? = null, classes : String? = null, crossinline block : IMG.() -> Unit = {}) : Unit = IMG(attributesMapOf("alt", alt,"src", src,"loading", ImgLoading.lazy.realValue,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.lazyImg(alt : String? = null, src : String? = null, classes : String? = null, crossinline block : IMG.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + IMG(attributesMapOf("alt", alt,"src", src,"loading", ImgLoading.lazy.realValue,"class", classes), consumer).visit(block) +} /** * Pictures container */ @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.picture(crossinline block : PICTURE.() -> Unit = {}) : Unit = PICTURE(emptyMap, consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.picture(crossinline block : PICTURE.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + PICTURE(emptyMap, consumer).visit(block) +} /** * Form control */ @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.input(type : InputType? = null, formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit = INPUT(attributesMapOf("type", type?.enumEncode(),"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.input(type : InputType? = null, formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + INPUT(attributesMapOf("type", type?.enumEncode(),"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.buttonInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit = INPUT(attributesMapOf("type", InputType.button.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.buttonInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + INPUT(attributesMapOf("type", InputType.button.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.checkBoxInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit = INPUT(attributesMapOf("type", InputType.checkBox.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.checkBoxInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + INPUT(attributesMapOf("type", InputType.checkBox.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.colorInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit = INPUT(attributesMapOf("type", InputType.color.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.colorInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + INPUT(attributesMapOf("type", InputType.color.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.dateInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit = INPUT(attributesMapOf("type", InputType.date.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.dateInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + INPUT(attributesMapOf("type", InputType.date.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.dateTimeInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit = INPUT(attributesMapOf("type", InputType.dateTime.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.dateTimeInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + INPUT(attributesMapOf("type", InputType.dateTime.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.dateTimeLocalInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit = INPUT(attributesMapOf("type", InputType.dateTimeLocal.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.dateTimeLocalInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + INPUT(attributesMapOf("type", InputType.dateTimeLocal.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.emailInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit = INPUT(attributesMapOf("type", InputType.email.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.emailInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + INPUT(attributesMapOf("type", InputType.email.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.fileInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit = INPUT(attributesMapOf("type", InputType.file.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.fileInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + INPUT(attributesMapOf("type", InputType.file.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.hiddenInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit = INPUT(attributesMapOf("type", InputType.hidden.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.hiddenInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + INPUT(attributesMapOf("type", InputType.hidden.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.imageInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit = INPUT(attributesMapOf("type", InputType.image.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.imageInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + INPUT(attributesMapOf("type", InputType.image.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.monthInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit = INPUT(attributesMapOf("type", InputType.month.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.monthInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + INPUT(attributesMapOf("type", InputType.month.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.numberInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit = INPUT(attributesMapOf("type", InputType.number.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.numberInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + INPUT(attributesMapOf("type", InputType.number.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.passwordInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit = INPUT(attributesMapOf("type", InputType.password.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.passwordInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + INPUT(attributesMapOf("type", InputType.password.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.radioInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit = INPUT(attributesMapOf("type", InputType.radio.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.radioInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + INPUT(attributesMapOf("type", InputType.radio.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.rangeInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit = INPUT(attributesMapOf("type", InputType.range.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.rangeInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + INPUT(attributesMapOf("type", InputType.range.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.resetInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit = INPUT(attributesMapOf("type", InputType.reset.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.resetInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + INPUT(attributesMapOf("type", InputType.reset.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.searchInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit = INPUT(attributesMapOf("type", InputType.search.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.searchInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + INPUT(attributesMapOf("type", InputType.search.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.submitInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit = INPUT(attributesMapOf("type", InputType.submit.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.submitInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + INPUT(attributesMapOf("type", InputType.submit.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.textInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit = INPUT(attributesMapOf("type", InputType.text.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.textInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + INPUT(attributesMapOf("type", InputType.text.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.telInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit = INPUT(attributesMapOf("type", InputType.tel.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.telInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + INPUT(attributesMapOf("type", InputType.tel.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.timeInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit = INPUT(attributesMapOf("type", InputType.time.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.timeInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + INPUT(attributesMapOf("type", InputType.time.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.urlInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit = INPUT(attributesMapOf("type", InputType.url.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.urlInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + INPUT(attributesMapOf("type", InputType.url.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.weekInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit = INPUT(attributesMapOf("type", InputType.week.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.weekInput(formEncType : InputFormEncType? = null, formMethod : InputFormMethod? = null, name : String? = null, classes : String? = null, crossinline block : INPUT.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + INPUT(attributesMapOf("type", InputType.week.realValue,"formenctype", formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), consumer).visit(block) +} /** * Cryptographic key-pair generator form control */ @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.keyGen(keyType : KeyGenKeyType? = null, classes : String? = null, crossinline block : KEYGEN.() -> Unit = {}) : Unit = KEYGEN(attributesMapOf("keytype", keyType?.enumEncode(),"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.keyGen(keyType : KeyGenKeyType? = null, classes : String? = null, crossinline block : KEYGEN.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + KEYGEN(attributesMapOf("keytype", keyType?.enumEncode(),"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.rsaKeyGen(classes : String? = null, crossinline block : KEYGEN.() -> Unit = {}) : Unit = KEYGEN(attributesMapOf("keytype", KeyGenKeyType.rsa.realValue,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.rsaKeyGen(classes : String? = null, crossinline block : KEYGEN.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + KEYGEN(attributesMapOf("keytype", KeyGenKeyType.rsa.realValue,"class", classes), consumer).visit(block) +} /** * Form field label text */ @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.label(classes : String? = null, crossinline block : LABEL.() -> Unit = {}) : Unit = LABEL(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.label(classes : String? = null, crossinline block : LABEL.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + LABEL(attributesMapOf("class", classes), consumer).visit(block) +} /** * Generic embedded object */ @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.htmlObject(classes : String? = null, crossinline block : OBJECT.() -> Unit = {}) : Unit = OBJECT(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.htmlObject(classes : String? = null, crossinline block : OBJECT.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + OBJECT(attributesMapOf("class", classes), consumer).visit(block) +} /** * Option selector */ @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.select(classes : String? = null, crossinline block : SELECT.() -> Unit = {}) : Unit = SELECT(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.select(classes : String? = null, crossinline block : SELECT.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + SELECT(attributesMapOf("class", classes), consumer).visit(block) +} /** * Multi-line text field */ @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.textArea(rows : String? = null, cols : String? = null, wrap : TextAreaWrap? = null, classes : String? = null, crossinline block : TEXTAREA.() -> Unit = {}) : Unit = TEXTAREA(attributesMapOf("rows", rows,"cols", cols,"wrap", wrap?.enumEncode(),"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.textArea(rows : String? = null, cols : String? = null, wrap : TextAreaWrap? = null, classes : String? = null, crossinline block : TEXTAREA.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + TEXTAREA(attributesMapOf("rows", rows,"cols", cols,"wrap", wrap?.enumEncode(),"class", classes), consumer).visit(block) +} /** * Multi-line text field */ @HtmlTagMarker fun FlowOrInteractiveOrPhrasingContent.textArea(rows : String? = null, cols : String? = null, wrap : TextAreaWrap? = null, classes : String? = null, content : String = "") : Unit = TEXTAREA(attributesMapOf("rows", rows,"cols", cols,"wrap", wrap?.enumEncode(),"class", classes), consumer).visit({+content}) @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.hardTextArea(rows : String? = null, cols : String? = null, classes : String? = null, crossinline block : TEXTAREA.() -> Unit = {}) : Unit = TEXTAREA(attributesMapOf("rows", rows,"cols", cols,"wrap", TextAreaWrap.hard.realValue,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.hardTextArea(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.hard.realValue,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.softTextArea(rows : String? = null, cols : String? = null, classes : String? = null, crossinline block : TEXTAREA.() -> Unit = {}) : Unit = TEXTAREA(attributesMapOf("rows", rows,"cols", cols,"wrap", TextAreaWrap.soft.realValue,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.softTextArea(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.soft.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 @@ -560,6 +1003,10 @@ fun FlowOrInteractiveOrPhrasingContent.softTextArea(rows : String? = null, cols * Video player */ @HtmlTagMarker -inline fun FlowOrInteractiveOrPhrasingContent.video(classes : String? = null, crossinline block : VIDEO.() -> Unit = {}) : Unit = VIDEO(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FlowOrInteractiveOrPhrasingContent.video(classes : String? = null, crossinline block : VIDEO.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + VIDEO(attributesMapOf("class", classes), consumer).visit(block) +} diff --git a/src/commonMain/kotlin/generated/gen-tags-a.kt b/src/commonMain/kotlin/generated/gen-tags-a.kt index 6d58a136..120c7576 100644 --- a/src/commonMain/kotlin/generated/gen-tags-a.kt +++ b/src/commonMain/kotlin/generated/gen-tags-a.kt @@ -1,5 +1,8 @@ package kotlinx.html +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract import kotlinx.html.* import kotlinx.html.impl.* import kotlinx.html.attributes.* @@ -160,7 +163,11 @@ open class AUDIO(initialAttributes : Map, override val consumer * Media source for */ @HtmlTagMarker -inline fun AUDIO.source(classes : String? = null, crossinline block : SOURCE.() -> Unit = {}) : Unit = SOURCE(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun AUDIO.source(classes : String? = null, crossinline block : SOURCE.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + SOURCE(attributesMapOf("class", classes), consumer).visit(block) +} val AUDIO.asFlowContent : FlowContent get() = this diff --git a/src/commonMain/kotlin/generated/gen-tags-b.kt b/src/commonMain/kotlin/generated/gen-tags-b.kt index 6862a2a4..1cb53792 100644 --- a/src/commonMain/kotlin/generated/gen-tags-b.kt +++ b/src/commonMain/kotlin/generated/gen-tags-b.kt @@ -1,5 +1,8 @@ package kotlinx.html +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract import kotlinx.html.* import kotlinx.html.impl.* import kotlinx.html.attributes.* diff --git a/src/commonMain/kotlin/generated/gen-tags-c.kt b/src/commonMain/kotlin/generated/gen-tags-c.kt index 49e80356..38f5c552 100644 --- a/src/commonMain/kotlin/generated/gen-tags-c.kt +++ b/src/commonMain/kotlin/generated/gen-tags-c.kt @@ -1,5 +1,8 @@ package kotlinx.html +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract import kotlinx.html.* import kotlinx.html.impl.* import kotlinx.html.attributes.* @@ -76,7 +79,11 @@ open class COLGROUP(initialAttributes : Map, override val consum * Table column */ @HtmlTagMarker -inline fun COLGROUP.col(classes : String? = null, crossinline block : COL.() -> Unit = {}) : Unit = COL(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun COLGROUP.col(classes : String? = null, crossinline block : COL.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + COL(attributesMapOf("class", classes), consumer).visit(block) +} @Suppress("unused") diff --git a/src/commonMain/kotlin/generated/gen-tags-d.kt b/src/commonMain/kotlin/generated/gen-tags-d.kt index f1bfa86a..1d72ae00 100644 --- a/src/commonMain/kotlin/generated/gen-tags-d.kt +++ b/src/commonMain/kotlin/generated/gen-tags-d.kt @@ -1,5 +1,8 @@ package kotlinx.html +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract import kotlinx.html.* import kotlinx.html.impl.* import kotlinx.html.attributes.* @@ -17,7 +20,11 @@ open class DATALIST(initialAttributes : Map, override val consum * Selectable choice */ @HtmlTagMarker -inline fun DATALIST.option(classes : String? = null, crossinline block : OPTION.() -> Unit = {}) : Unit = OPTION(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun DATALIST.option(classes : String? = null, crossinline block : OPTION.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + OPTION(attributesMapOf("class", classes), consumer).visit(block) +} /** * Selectable choice */ @@ -67,7 +74,11 @@ open class DETAILS(initialAttributes : Map, override val consume * Fieldset legend */ @HtmlTagMarker -inline fun DETAILS.legend(classes : String? = null, crossinline block : LEGEND.() -> Unit = {}) : Unit = LEGEND(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun DETAILS.legend(classes : String? = null, crossinline block : LEGEND.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + LEGEND(attributesMapOf("class", classes), consumer).visit(block) +} val DETAILS.asFlowContent : FlowContent get() = this @@ -105,13 +116,21 @@ open class DL(initialAttributes : Map, override val consumer : T * Definition description */ @HtmlTagMarker -inline fun DL.dd(classes : String? = null, crossinline block : DD.() -> Unit = {}) : Unit = DD(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun DL.dd(classes : String? = null, crossinline block : DD.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + DD(attributesMapOf("class", classes), consumer).visit(block) +} /** * Definition term */ @HtmlTagMarker -inline fun DL.dt(classes : String? = null, crossinline block : DT.() -> Unit = {}) : Unit = DT(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun DL.dt(classes : String? = null, crossinline block : DT.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + DT(attributesMapOf("class", classes), consumer).visit(block) +} @Suppress("unused") diff --git a/src/commonMain/kotlin/generated/gen-tags-e.kt b/src/commonMain/kotlin/generated/gen-tags-e.kt index 4142c01d..b89e2444 100644 --- a/src/commonMain/kotlin/generated/gen-tags-e.kt +++ b/src/commonMain/kotlin/generated/gen-tags-e.kt @@ -1,5 +1,8 @@ package kotlinx.html +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract import kotlinx.html.* import kotlinx.html.impl.* import kotlinx.html.attributes.* diff --git a/src/commonMain/kotlin/generated/gen-tags-f.kt b/src/commonMain/kotlin/generated/gen-tags-f.kt index 984b0200..02a97578 100644 --- a/src/commonMain/kotlin/generated/gen-tags-f.kt +++ b/src/commonMain/kotlin/generated/gen-tags-f.kt @@ -1,5 +1,8 @@ package kotlinx.html +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract import kotlinx.html.* import kotlinx.html.impl.* import kotlinx.html.attributes.* @@ -29,7 +32,11 @@ open class FIELDSET(initialAttributes : Map, override val consum * Fieldset legend */ @HtmlTagMarker -inline fun FIELDSET.legend(classes : String? = null, crossinline block : LEGEND.() -> Unit = {}) : Unit = LEGEND(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FIELDSET.legend(classes : String? = null, crossinline block : LEGEND.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + LEGEND(attributesMapOf("class", classes), consumer).visit(block) +} @Suppress("unused") @@ -45,13 +52,21 @@ open class FIGURE(initialAttributes : Map, override val consumer * Fieldset legend */ @HtmlTagMarker -inline fun FIGURE.legend(classes : String? = null, crossinline block : LEGEND.() -> Unit = {}) : Unit = LEGEND(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FIGURE.legend(classes : String? = null, crossinline block : LEGEND.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + LEGEND(attributesMapOf("class", classes), consumer).visit(block) +} /** * Caption for */ @HtmlTagMarker -inline fun FIGURE.figcaption(classes : String? = null, crossinline block : FIGCAPTION.() -> Unit = {}) : Unit = FIGCAPTION(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun FIGURE.figcaption(classes : String? = null, crossinline block : FIGCAPTION.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + FIGCAPTION(attributesMapOf("class", classes), consumer).visit(block) +} @Suppress("unused") diff --git a/src/commonMain/kotlin/generated/gen-tags-h.kt b/src/commonMain/kotlin/generated/gen-tags-h.kt index b1e312a2..6bbe5217 100644 --- a/src/commonMain/kotlin/generated/gen-tags-h.kt +++ b/src/commonMain/kotlin/generated/gen-tags-h.kt @@ -1,5 +1,8 @@ package kotlinx.html +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract import kotlinx.html.* import kotlinx.html.impl.* import kotlinx.html.attributes.* @@ -81,37 +84,61 @@ open class HGROUP(initialAttributes : Map, override val consumer * Heading */ @HtmlTagMarker -inline fun HGROUP.h1(classes : String? = null, crossinline block : H1.() -> Unit = {}) : Unit = H1(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun HGROUP.h1(classes : String? = null, crossinline block : H1.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + H1(attributesMapOf("class", classes), consumer).visit(block) +} /** * Heading */ @HtmlTagMarker -inline fun HGROUP.h2(classes : String? = null, crossinline block : H2.() -> Unit = {}) : Unit = H2(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun HGROUP.h2(classes : String? = null, crossinline block : H2.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + H2(attributesMapOf("class", classes), consumer).visit(block) +} /** * Heading */ @HtmlTagMarker -inline fun HGROUP.h3(classes : String? = null, crossinline block : H3.() -> Unit = {}) : Unit = H3(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun HGROUP.h3(classes : String? = null, crossinline block : H3.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + H3(attributesMapOf("class", classes), consumer).visit(block) +} /** * Heading */ @HtmlTagMarker -inline fun HGROUP.h4(classes : String? = null, crossinline block : H4.() -> Unit = {}) : Unit = H4(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun HGROUP.h4(classes : String? = null, crossinline block : H4.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + H4(attributesMapOf("class", classes), consumer).visit(block) +} /** * Heading */ @HtmlTagMarker -inline fun HGROUP.h5(classes : String? = null, crossinline block : H5.() -> Unit = {}) : Unit = H5(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun HGROUP.h5(classes : String? = null, crossinline block : H5.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + H5(attributesMapOf("class", classes), consumer).visit(block) +} /** * Heading */ @HtmlTagMarker -inline fun HGROUP.h6(classes : String? = null, crossinline block : H6.() -> Unit = {}) : Unit = H6(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun HGROUP.h6(classes : String? = null, crossinline block : H6.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + H6(attributesMapOf("class", classes), consumer).visit(block) +} val HGROUP.asFlowContent : FlowContent get() = this @@ -161,13 +188,21 @@ open class HTML(initialAttributes : Map, override val consumer : * Document body */ @HtmlTagMarker -inline fun HTML.body(classes : String? = null, crossinline block : BODY.() -> Unit = {}) : Unit = BODY(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun HTML.body(classes : String? = null, crossinline block : BODY.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + BODY(attributesMapOf("class", classes), consumer).visit(block) +} /** * Document head */ @HtmlTagMarker -inline fun HTML.head(crossinline block : HEAD.() -> Unit = {}) : Unit = HEAD(emptyMap, consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun HTML.head(crossinline block : HEAD.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + HEAD(emptyMap, consumer).visit(block) +} @Deprecated("This tag doesn't support content or requires unsafe (try unsafe {})") @Suppress("DEPRECATION") /** diff --git a/src/commonMain/kotlin/generated/gen-tags-i.kt b/src/commonMain/kotlin/generated/gen-tags-i.kt index 8c47e290..4bb080a2 100644 --- a/src/commonMain/kotlin/generated/gen-tags-i.kt +++ b/src/commonMain/kotlin/generated/gen-tags-i.kt @@ -1,5 +1,8 @@ package kotlinx.html +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract import kotlinx.html.* import kotlinx.html.impl.* import kotlinx.html.attributes.* diff --git a/src/commonMain/kotlin/generated/gen-tags-k.kt b/src/commonMain/kotlin/generated/gen-tags-k.kt index 79d972d3..e4902126 100644 --- a/src/commonMain/kotlin/generated/gen-tags-k.kt +++ b/src/commonMain/kotlin/generated/gen-tags-k.kt @@ -1,5 +1,8 @@ package kotlinx.html +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract import kotlinx.html.* import kotlinx.html.impl.* import kotlinx.html.attributes.* diff --git a/src/commonMain/kotlin/generated/gen-tags-l.kt b/src/commonMain/kotlin/generated/gen-tags-l.kt index be7eb8b4..15286c62 100644 --- a/src/commonMain/kotlin/generated/gen-tags-l.kt +++ b/src/commonMain/kotlin/generated/gen-tags-l.kt @@ -1,5 +1,8 @@ package kotlinx.html +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract import kotlinx.html.* import kotlinx.html.impl.* import kotlinx.html.attributes.* diff --git a/src/commonMain/kotlin/generated/gen-tags-m.kt b/src/commonMain/kotlin/generated/gen-tags-m.kt index 6201f6c4..b16c1038 100644 --- a/src/commonMain/kotlin/generated/gen-tags-m.kt +++ b/src/commonMain/kotlin/generated/gen-tags-m.kt @@ -1,5 +1,8 @@ package kotlinx.html +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract import kotlinx.html.* import kotlinx.html.impl.* import kotlinx.html.attributes.* diff --git a/src/commonMain/kotlin/generated/gen-tags-n.kt b/src/commonMain/kotlin/generated/gen-tags-n.kt index 689755c0..bebf3cf3 100644 --- a/src/commonMain/kotlin/generated/gen-tags-n.kt +++ b/src/commonMain/kotlin/generated/gen-tags-n.kt @@ -1,5 +1,8 @@ package kotlinx.html +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract import kotlinx.html.* import kotlinx.html.impl.* import kotlinx.html.attributes.* diff --git a/src/commonMain/kotlin/generated/gen-tags-o.kt b/src/commonMain/kotlin/generated/gen-tags-o.kt index cf8d0ef3..73e1f0e3 100644 --- a/src/commonMain/kotlin/generated/gen-tags-o.kt +++ b/src/commonMain/kotlin/generated/gen-tags-o.kt @@ -1,5 +1,8 @@ package kotlinx.html +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract import kotlinx.html.* import kotlinx.html.impl.* import kotlinx.html.attributes.* @@ -49,7 +52,11 @@ open class OBJECT(initialAttributes : Map, override val consumer * Named property value */ @HtmlTagMarker -inline fun OBJECT.param(name : String? = null, value : String? = null, crossinline block : PARAM.() -> Unit = {}) : Unit = PARAM(attributesMapOf("name", name,"value", value), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun OBJECT.param(name : String? = null, value : String? = null, crossinline block : PARAM.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + PARAM(attributesMapOf("name", name,"value", value), consumer).visit(block) +} val OBJECT.asFlowContent : FlowContent get() = this @@ -77,7 +84,11 @@ open class OL(initialAttributes : Map, override val consumer : T * List item */ @HtmlTagMarker -inline fun OL.li(classes : String? = null, crossinline block : LI.() -> Unit = {}) : Unit = LI(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun OL.li(classes : String? = null, crossinline block : LI.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + LI(attributesMapOf("class", classes), consumer).visit(block) +} @Suppress("unused") @@ -96,7 +107,11 @@ open class OPTGROUP(initialAttributes : Map, override val consum * Selectable choice */ @HtmlTagMarker -inline fun OPTGROUP.option(classes : String? = null, crossinline block : OPTION.() -> Unit = {}) : Unit = OPTION(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun OPTGROUP.option(classes : String? = null, crossinline block : OPTION.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + OPTION(attributesMapOf("class", classes), consumer).visit(block) +} /** * Selectable choice */ diff --git a/src/commonMain/kotlin/generated/gen-tags-p.kt b/src/commonMain/kotlin/generated/gen-tags-p.kt index df3501e8..ef9257f0 100644 --- a/src/commonMain/kotlin/generated/gen-tags-p.kt +++ b/src/commonMain/kotlin/generated/gen-tags-p.kt @@ -1,5 +1,8 @@ package kotlinx.html +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract import kotlinx.html.* import kotlinx.html.impl.* import kotlinx.html.attributes.* @@ -41,17 +44,33 @@ open class PICTURE(initialAttributes : Map, override val consume * Media source for */ @HtmlTagMarker -inline fun PICTURE.source(classes : String? = null, crossinline block : SOURCE.() -> Unit = {}) : Unit = SOURCE(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun PICTURE.source(classes : String? = null, crossinline block : SOURCE.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + SOURCE(attributesMapOf("class", classes), consumer).visit(block) +} /** * Embedded image */ @HtmlTagMarker -inline fun PICTURE.img(alt : String? = null, src : String? = null, loading : ImgLoading? = null, classes : String? = null, crossinline block : IMG.() -> Unit = {}) : Unit = IMG(attributesMapOf("alt", alt,"src", src,"loading", loading?.enumEncode(),"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun PICTURE.img(alt : String? = null, src : String? = null, loading : ImgLoading? = null, classes : String? = null, crossinline block : IMG.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + IMG(attributesMapOf("alt", alt,"src", src,"loading", loading?.enumEncode(),"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun PICTURE.eagerImg(alt : String? = null, src : String? = null, classes : String? = null, crossinline block : IMG.() -> Unit = {}) : Unit = IMG(attributesMapOf("alt", alt,"src", src,"loading", ImgLoading.eager.realValue,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun PICTURE.eagerImg(alt : String? = null, src : String? = null, classes : String? = null, crossinline block : IMG.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + IMG(attributesMapOf("alt", alt,"src", src,"loading", ImgLoading.eager.realValue,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun PICTURE.lazyImg(alt : String? = null, src : String? = null, classes : String? = null, crossinline block : IMG.() -> Unit = {}) : Unit = IMG(attributesMapOf("alt", alt,"src", src,"loading", ImgLoading.lazy.realValue,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun PICTURE.lazyImg(alt : String? = null, src : String? = null, classes : String? = null, crossinline block : IMG.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + IMG(attributesMapOf("alt", alt,"src", src,"loading", ImgLoading.lazy.realValue,"class", classes), consumer).visit(block) +} val PICTURE.asFlowContent : FlowContent get() = this diff --git a/src/commonMain/kotlin/generated/gen-tags-q.kt b/src/commonMain/kotlin/generated/gen-tags-q.kt index ac64e5be..1eb0519b 100644 --- a/src/commonMain/kotlin/generated/gen-tags-q.kt +++ b/src/commonMain/kotlin/generated/gen-tags-q.kt @@ -1,5 +1,8 @@ package kotlinx.html +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract import kotlinx.html.* import kotlinx.html.impl.* import kotlinx.html.attributes.* diff --git a/src/commonMain/kotlin/generated/gen-tags-r.kt b/src/commonMain/kotlin/generated/gen-tags-r.kt index c3c9d7e1..37d2b477 100644 --- a/src/commonMain/kotlin/generated/gen-tags-r.kt +++ b/src/commonMain/kotlin/generated/gen-tags-r.kt @@ -1,5 +1,8 @@ package kotlinx.html +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract import kotlinx.html.* import kotlinx.html.impl.* import kotlinx.html.attributes.* @@ -27,13 +30,21 @@ open class RUBY(initialAttributes : Map, override val consumer : * Ruby annotation text */ @HtmlTagMarker -inline fun RUBY.rt(classes : String? = null, crossinline block : RT.() -> Unit = {}) : Unit = RT(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun RUBY.rt(classes : String? = null, crossinline block : RT.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + RT(attributesMapOf("class", classes), consumer).visit(block) +} /** * Parenthesis for ruby annotation text */ @HtmlTagMarker -inline fun RUBY.rp(classes : String? = null, crossinline block : RP.() -> Unit = {}) : Unit = RP(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun RUBY.rp(classes : String? = null, crossinline block : RP.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + RP(attributesMapOf("class", classes), consumer).visit(block) +} val RUBY.asFlowContent : FlowContent get() = this diff --git a/src/commonMain/kotlin/generated/gen-tags-s.kt b/src/commonMain/kotlin/generated/gen-tags-s.kt index be98de13..6be14c8d 100644 --- a/src/commonMain/kotlin/generated/gen-tags-s.kt +++ b/src/commonMain/kotlin/generated/gen-tags-s.kt @@ -1,5 +1,8 @@ package kotlinx.html +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract import kotlinx.html.* import kotlinx.html.impl.* import kotlinx.html.attributes.* @@ -148,7 +151,11 @@ open class SELECT(initialAttributes : Map, override val consumer * Selectable choice */ @HtmlTagMarker -inline fun SELECT.option(classes : String? = null, crossinline block : OPTION.() -> Unit = {}) : Unit = OPTION(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun SELECT.option(classes : String? = null, crossinline block : OPTION.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + OPTION(attributesMapOf("class", classes), consumer).visit(block) +} /** * Selectable choice */ @@ -159,7 +166,11 @@ fun SELECT.option(classes : String? = null, content : String = "") : Unit = OPTI * Option group */ @HtmlTagMarker -inline fun SELECT.optGroup(label : String? = null, classes : String? = null, crossinline block : OPTGROUP.() -> Unit = {}) : Unit = OPTGROUP(attributesMapOf("label", label,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun SELECT.optGroup(label : String? = null, classes : String? = null, crossinline block : OPTGROUP.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + OPTGROUP(attributesMapOf("label", label,"class", classes), consumer).visit(block) +} val SELECT.asFlowContent : FlowContent get() = this diff --git a/src/commonMain/kotlin/generated/gen-tags-t.kt b/src/commonMain/kotlin/generated/gen-tags-t.kt index 5f02d65e..a99a678d 100644 --- a/src/commonMain/kotlin/generated/gen-tags-t.kt +++ b/src/commonMain/kotlin/generated/gen-tags-t.kt @@ -1,5 +1,8 @@ package kotlinx.html +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract import kotlinx.html.* import kotlinx.html.impl.* import kotlinx.html.attributes.* @@ -21,37 +24,61 @@ open class TABLE(initialAttributes : Map, override val consumer * Table caption */ @HtmlTagMarker -inline fun TABLE.caption(classes : String? = null, crossinline block : CAPTION.() -> Unit = {}) : Unit = CAPTION(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun TABLE.caption(classes : String? = null, crossinline block : CAPTION.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + CAPTION(attributesMapOf("class", classes), consumer).visit(block) +} /** * Table column group */ @HtmlTagMarker -inline fun TABLE.colGroup(classes : String? = null, crossinline block : COLGROUP.() -> Unit = {}) : Unit = COLGROUP(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun TABLE.colGroup(classes : String? = null, crossinline block : COLGROUP.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + COLGROUP(attributesMapOf("class", classes), consumer).visit(block) +} /** * Table header */ @HtmlTagMarker -inline fun TABLE.thead(classes : String? = null, crossinline block : THEAD.() -> Unit = {}) : Unit = THEAD(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun TABLE.thead(classes : String? = null, crossinline block : THEAD.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + THEAD(attributesMapOf("class", classes), consumer).visit(block) +} /** * Table footer */ @HtmlTagMarker -inline fun TABLE.tfoot(classes : String? = null, crossinline block : TFOOT.() -> Unit = {}) : Unit = TFOOT(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun TABLE.tfoot(classes : String? = null, crossinline block : TFOOT.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + TFOOT(attributesMapOf("class", classes), consumer).visit(block) +} /** * Table body */ @HtmlTagMarker -inline fun TABLE.tbody(classes : String? = null, crossinline block : TBODY.() -> Unit = {}) : Unit = TBODY(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun TABLE.tbody(classes : String? = null, crossinline block : TBODY.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + TBODY(attributesMapOf("class", classes), consumer).visit(block) +} /** * Table row */ @HtmlTagMarker -inline fun TABLE.tr(classes : String? = null, crossinline block : TR.() -> Unit = {}) : Unit = TR(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun TABLE.tr(classes : String? = null, crossinline block : TR.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + TR(attributesMapOf("class", classes), consumer).visit(block) +} @Suppress("unused") @@ -62,7 +89,11 @@ open class TBODY(initialAttributes : Map, override val consumer * Table row */ @HtmlTagMarker -inline fun TBODY.tr(classes : String? = null, crossinline block : TR.() -> Unit = {}) : Unit = TR(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun TBODY.tr(classes : String? = null, crossinline block : TR.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + TR(attributesMapOf("class", classes), consumer).visit(block) +} @Suppress("unused") @@ -163,7 +194,11 @@ open class TFOOT(initialAttributes : Map, override val consumer * Table row */ @HtmlTagMarker -inline fun TFOOT.tr(classes : String? = null, crossinline block : TR.() -> Unit = {}) : Unit = TR(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun TFOOT.tr(classes : String? = null, crossinline block : TR.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + TR(attributesMapOf("class", classes), consumer).visit(block) +} @Suppress("unused") @@ -195,7 +230,11 @@ open class THEAD(initialAttributes : Map, override val consumer * Table row */ @HtmlTagMarker -inline fun THEAD.tr(classes : String? = null, crossinline block : TR.() -> Unit = {}) : Unit = TR(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun THEAD.tr(classes : String? = null, crossinline block : TR.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + TR(attributesMapOf("class", classes), consumer).visit(block) +} @Suppress("unused") @@ -226,20 +265,44 @@ open class TR(initialAttributes : Map, override val consumer : T * Table header cell */ @HtmlTagMarker -inline fun TR.th(scope : ThScope? = null, classes : String? = null, crossinline block : TH.() -> Unit = {}) : Unit = TH(attributesMapOf("scope", scope?.enumEncode(),"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun TR.th(scope : ThScope? = null, classes : String? = null, crossinline block : TH.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + TH(attributesMapOf("scope", scope?.enumEncode(),"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun TR.colTh(classes : String? = null, crossinline block : TH.() -> Unit = {}) : Unit = TH(attributesMapOf("scope", ThScope.col.realValue,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun TR.colTh(classes : String? = null, crossinline block : TH.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + TH(attributesMapOf("scope", ThScope.col.realValue,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun TR.colGroupTh(classes : String? = null, crossinline block : TH.() -> Unit = {}) : Unit = TH(attributesMapOf("scope", ThScope.colGroup.realValue,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun TR.colGroupTh(classes : String? = null, crossinline block : TH.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + TH(attributesMapOf("scope", ThScope.colGroup.realValue,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun TR.rowTh(classes : String? = null, crossinline block : TH.() -> Unit = {}) : Unit = TH(attributesMapOf("scope", ThScope.row.realValue,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun TR.rowTh(classes : String? = null, crossinline block : TH.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + TH(attributesMapOf("scope", ThScope.row.realValue,"class", classes), consumer).visit(block) +} @HtmlTagMarker -inline fun TR.rowGroupTh(classes : String? = null, crossinline block : TH.() -> Unit = {}) : Unit = TH(attributesMapOf("scope", ThScope.rowGroup.realValue,"class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun TR.rowGroupTh(classes : String? = null, crossinline block : TH.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + TH(attributesMapOf("scope", ThScope.rowGroup.realValue,"class", classes), consumer).visit(block) +} /** * Table data cell */ @HtmlTagMarker -inline fun TR.td(classes : String? = null, crossinline block : TD.() -> Unit = {}) : Unit = TD(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun TR.td(classes : String? = null, crossinline block : TD.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + TD(attributesMapOf("class", classes), consumer).visit(block) +} diff --git a/src/commonMain/kotlin/generated/gen-tags-u.kt b/src/commonMain/kotlin/generated/gen-tags-u.kt index 93cb16f4..07227fa0 100644 --- a/src/commonMain/kotlin/generated/gen-tags-u.kt +++ b/src/commonMain/kotlin/generated/gen-tags-u.kt @@ -1,5 +1,8 @@ package kotlinx.html +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract import kotlinx.html.* import kotlinx.html.impl.* import kotlinx.html.attributes.* @@ -28,6 +31,10 @@ open class UL(initialAttributes : Map, override val consumer : T * List item */ @HtmlTagMarker -inline fun UL.li(classes : String? = null, crossinline block : LI.() -> Unit = {}) : Unit = LI(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun UL.li(classes : String? = null, crossinline block : LI.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + LI(attributesMapOf("class", classes), consumer).visit(block) +} diff --git a/src/commonMain/kotlin/generated/gen-tags-v.kt b/src/commonMain/kotlin/generated/gen-tags-v.kt index 76f5c0ff..5dc042fa 100644 --- a/src/commonMain/kotlin/generated/gen-tags-v.kt +++ b/src/commonMain/kotlin/generated/gen-tags-v.kt @@ -1,5 +1,8 @@ package kotlinx.html +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract import kotlinx.html.* import kotlinx.html.impl.* import kotlinx.html.attributes.* @@ -60,7 +63,11 @@ open class VIDEO(initialAttributes : Map, override val consumer * Media source for */ @HtmlTagMarker -inline fun VIDEO.source(classes : String? = null, crossinline block : SOURCE.() -> Unit = {}) : Unit = SOURCE(attributesMapOf("class", classes), consumer).visit(block) +@OptIn(ExperimentalContracts::class) +inline fun VIDEO.source(classes : String? = null, crossinline block : SOURCE.() -> Unit = {}) : Unit { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + SOURCE(attributesMapOf("class", classes), consumer).visit(block) +} val VIDEO.asFlowContent : FlowContent get() = this diff --git a/src/commonTest/kotlin/AttributesTest.kt b/src/commonTest/kotlin/AttributesTest.kt index 08937179..84478bde 100644 --- a/src/commonTest/kotlin/AttributesTest.kt +++ b/src/commonTest/kotlin/AttributesTest.kt @@ -7,13 +7,17 @@ class AttributesTest { @Test fun testEscapedChar() { + val dataTest = "Test: \\…" + val dataTestAttribute: String? val html = buildString { appendHTML(false).div { - attributes["data-test"] = "Test: \\…" + attributes["data-test"] = dataTest + dataTestAttribute = attributes["data-test"] } } val message = "
" assertEquals(message, html) + assertEquals(dataTest, dataTestAttribute) } } \ No newline at end of file diff --git a/src/jsMain/kotlin/dom-js.kt b/src/jsMain/kotlin/dom-js.kt index 2f60ec69..b1622317 100644 --- a/src/jsMain/kotlin/dom-js.kt +++ b/src/jsMain/kotlin/dom-js.kt @@ -1,12 +1,23 @@ package kotlinx.html.dom -import kotlinx.html.* -import kotlinx.html.consumers.* +import kotlinx.html.DefaultUnsafe +import kotlinx.html.Entities +import kotlinx.html.Tag +import kotlinx.html.TagConsumer +import kotlinx.html.Unsafe +import kotlinx.html.consumers.onFinalize import kotlinx.html.org.w3c.dom.events.Event -import org.w3c.dom.* +import org.w3c.dom.Document +import org.w3c.dom.Element +import org.w3c.dom.HTMLElement +import org.w3c.dom.Node +import org.w3c.dom.asList +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract import kotlin.reflect.KProperty -private inline fun HTMLElement.setEvent(name: String, noinline callback : (Event) -> Unit) : Unit { +private inline fun HTMLElement.setEvent(name: String, noinline callback : (Event) -> Unit) { asDynamic()[name] = callback } @@ -112,28 +123,31 @@ class JSDOMBuilder(val document : Document) : TagConsumer get() = JSDOMBuilder(this) -fun Node.append(block: TagConsumer.() -> Unit): List = - ArrayList().let { result -> +@OptIn(ExperimentalContracts::class) +fun Node.append(block: TagConsumer.() -> Unit): List { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return buildList { ownerDocumentExt.createTree().onFinalize { it, partial -> if (!partial) { - result.add(it); appendChild(it) + add(it) + appendChild(it) } }.block() - - result } +} -fun Node.prepend(block: TagConsumer.() -> Unit): List = - ArrayList().let { result -> +@OptIn(ExperimentalContracts::class) +fun Node.prepend(block: TagConsumer.() -> Unit): List { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return buildList { ownerDocumentExt.createTree().onFinalize { it, partial -> if (!partial) { - result.add(it) + add(it) insertBefore(it, firstChild) } }.block() - - result } +} val HTMLElement.append: TagConsumer get() = ownerDocumentExt.createTree().onFinalize { element, partial -> @@ -179,7 +193,7 @@ inline val Document.gettingElementById get() = DocumentGettingElementById(this) * Implementation details of [Document.gettingElementById] * @see Document.gettingElementById */ -inline class DocumentGettingElementById(val document: Document) { +value class DocumentGettingElementById(val document: Document) { /** * Implementation details of [Document.gettingElementById]. Delegated property * @see Document.gettingElementById diff --git a/src/jsMain/kotlin/generated/gen-consumer-tags-js.kt b/src/jsMain/kotlin/generated/gen-consumer-tags-js.kt index 2eeafd66..0da5c12d 100644 --- a/src/jsMain/kotlin/generated/gen-consumer-tags-js.kt +++ b/src/jsMain/kotlin/generated/gen-consumer-tags-js.kt @@ -4,6 +4,9 @@ *******************************************************************************/ package kotlinx.html.js +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract import kotlinx.html.* import kotlinx.html.attributes.* @@ -199,128 +202,183 @@ import org.w3c.dom.HTMLVideoElement * Anchor */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.a( href: String? = null, target: String? = null, classes: String? = null, crossinline block: A.() -> Unit = {}, -): HTMLAnchorElement = A(attributesMapOf("href", href,"target", target,"class", classes), this) - .visitAndFinalize(this, block) as HTMLAnchorElement +): HTMLAnchorElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return A(attributesMapOf("href", href,"target", target,"class", classes), this) + .visitAndFinalize(this, block) as HTMLAnchorElement +} /** * Abbreviated form (e.g., WWW, HTTP,etc.) */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.abbr(classes: String? = null, crossinline - block: ABBR.() -> Unit = {}): HTMLElement = ABBR(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: ABBR.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return ABBR(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Information on author */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.address(classes: String? = null, crossinline - block: ADDRESS.() -> Unit = {}): HTMLElement = ADDRESS(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: ADDRESS.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return ADDRESS(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Client-side image map area */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.area( shape: AreaShape? = null, alt: String? = null, classes: String? = null, crossinline block: AREA.() -> Unit = {}, -): HTMLAreaElement = AREA(attributesMapOf("Shape", shape?.enumEncode(),"alt", alt,"class", classes), - this) - .visitAndFinalize(this, block) as HTMLAreaElement +): HTMLAreaElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return AREA(attributesMapOf("Shape", shape?.enumEncode(),"alt", alt,"class", classes), this) + .visitAndFinalize(this, block) as HTMLAreaElement +} /** * Self-contained syndicatable or reusable composition */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.article(classes: String? = null, crossinline - block: ARTICLE.() -> Unit = {}): HTMLElement = ARTICLE(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: ARTICLE.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return ARTICLE(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Sidebar for tangentially related content */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.aside(classes: String? = null, crossinline - block: ASIDE.() -> Unit = {}): HTMLElement = ASIDE(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: ASIDE.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return ASIDE(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Audio player */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.audio(classes: String? = null, crossinline - block: AUDIO.() -> Unit = {}): HTMLAudioElement = AUDIO(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLAudioElement + block: AUDIO.() -> Unit = {}): HTMLAudioElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return AUDIO(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLAudioElement +} /** * Bold text style */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.b(classes: String? = null, crossinline - block: B.() -> Unit = {}): HTMLElement = B(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: B.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return B(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Document base URI */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.base(classes: String? = null, crossinline - block: BASE.() -> Unit = {}): HTMLBaseElement = BASE(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLBaseElement + block: BASE.() -> Unit = {}): HTMLBaseElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return BASE(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLBaseElement +} /** * Text directionality isolation */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.bdi(classes: String? = null, crossinline - block: BDI.() -> Unit = {}): HTMLElement = BDI(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: BDI.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return BDI(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * I18N BiDi over-ride */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.bdo(classes: String? = null, crossinline - block: BDO.() -> Unit = {}): HTMLElement = BDO(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: BDO.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return BDO(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Long quotation */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.blockQuote(classes: String? = null, crossinline - block: BLOCKQUOTE.() -> Unit = {}): HTMLElement = BLOCKQUOTE(attributesMapOf("class", classes), - this) - .visitAndFinalize(this, block) + block: BLOCKQUOTE.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return BLOCKQUOTE(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Document body */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.body(classes: String? = null, crossinline - block: BODY.() -> Unit = {}): HTMLBodyElement = BODY(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLBodyElement + block: BODY.() -> Unit = {}): HTMLBodyElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return BODY(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLBodyElement +} /** * Forced line break */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.br(classes: String? = null, crossinline - block: BR.() -> Unit = {}): HTMLBRElement = BR(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLBRElement + block: BR.() -> Unit = {}): HTMLBRElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return BR(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLBRElement +} /** * Push button */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.button( formEncType: ButtonFormEncType? = null, formMethod: ButtonFormMethod? = null, @@ -328,9 +386,12 @@ public inline fun TagConsumer.button( type: ButtonType? = null, classes: String? = null, crossinline block: BUTTON.() -> Unit = {}, -): HTMLButtonElement = BUTTON(attributesMapOf("formenctype", formEncType?.enumEncode(),"formmethod", - formMethod?.enumEncode(),"name", name,"type", type?.enumEncode(),"class", classes), this) - .visitAndFinalize(this, block) as HTMLButtonElement +): HTMLButtonElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return BUTTON(attributesMapOf("formenctype", formEncType?.enumEncode(),"formmethod", + formMethod?.enumEncode(),"name", name,"type", type?.enumEncode(),"class", classes), this) + .visitAndFinalize(this, block) as HTMLButtonElement +} /** * Scriptable bitmap canvas @@ -344,246 +405,355 @@ public fun TagConsumer.canvas(classes: String? = null, content: Str * Scriptable bitmap canvas */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.canvas(classes: String? = null, crossinline - block: CANVAS.() -> Unit = {}): HTMLCanvasElement = CANVAS(attributesMapOf("class", classes), - this) - .visitAndFinalize(this, block) as HTMLCanvasElement + block: CANVAS.() -> Unit = {}): HTMLCanvasElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return CANVAS(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLCanvasElement +} /** * Table caption */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.caption(classes: String? = null, crossinline - block: CAPTION.() -> Unit = {}): HTMLElement = CAPTION(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: CAPTION.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return CAPTION(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Citation */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.cite(classes: String? = null, crossinline - block: CITE.() -> Unit = {}): HTMLElement = CITE(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: CITE.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return CITE(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Computer code fragment */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.code(classes: String? = null, crossinline - block: CODE.() -> Unit = {}): HTMLElement = CODE(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: CODE.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return CODE(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Table column */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.col(classes: String? = null, crossinline - block: COL.() -> Unit = {}): HTMLTableColElement = COL(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLTableColElement + block: COL.() -> Unit = {}): HTMLTableColElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return COL(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLTableColElement +} /** * Table column group */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.colGroup(classes: String? = null, crossinline - block: COLGROUP.() -> Unit = {}): HTMLTableColElement = COLGROUP(attributesMapOf("class", - classes), this) - .visitAndFinalize(this, block) as HTMLTableColElement + block: COLGROUP.() -> Unit = {}): HTMLTableColElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return COLGROUP(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLTableColElement +} @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.command( type: CommandType? = null, classes: String? = null, crossinline block: COMMAND.() -> Unit = {}, -): HTMLElement = COMMAND(attributesMapOf("type", type?.enumEncode(),"class", classes), this) - .visitAndFinalize(this, block) +): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return COMMAND(attributesMapOf("type", type?.enumEncode(),"class", classes), this) + .visitAndFinalize(this, block) +} /** * Container for options for */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.dataList(classes: String? = null, crossinline - block: DATALIST.() -> Unit = {}): HTMLDataListElement = DATALIST(attributesMapOf("class", - classes), this) - .visitAndFinalize(this, block) as HTMLDataListElement + block: DATALIST.() -> Unit = {}): HTMLDataListElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return DATALIST(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLDataListElement +} /** * Definition description */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.dd(classes: String? = null, crossinline - block: DD.() -> Unit = {}): HTMLElement = DD(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: DD.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return DD(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Deleted text */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.del(classes: String? = null, crossinline - block: DEL.() -> Unit = {}): HTMLElement = DEL(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: DEL.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return DEL(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Disclosure control for hiding details */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.details(classes: String? = null, crossinline - block: DETAILS.() -> Unit = {}): HTMLDetailsElement = DETAILS(attributesMapOf("class", classes), - this) - .visitAndFinalize(this, block) as HTMLDetailsElement + block: DETAILS.() -> Unit = {}): HTMLDetailsElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return DETAILS(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLDetailsElement +} /** * Instance definition */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.dfn(classes: String? = null, crossinline - block: DFN.() -> Unit = {}): HTMLElement = DFN(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: DFN.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return DFN(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Dialog box or window */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.dialog(classes: String? = null, crossinline - block: DIALOG.() -> Unit = {}): HTMLDialogElement = DIALOG(attributesMapOf("class", classes), - this) - .visitAndFinalize(this, block) as HTMLDialogElement + block: DIALOG.() -> Unit = {}): HTMLDialogElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return DIALOG(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLDialogElement +} /** * Generic language/style container */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.div(classes: String? = null, crossinline - block: DIV.() -> Unit = {}): HTMLDivElement = DIV(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLDivElement + block: DIV.() -> Unit = {}): HTMLDivElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return DIV(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLDivElement +} /** * Definition list */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.dl(classes: String? = null, crossinline - block: DL.() -> Unit = {}): HTMLElement = DL(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: DL.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return DL(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Definition term */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.dt(classes: String? = null, crossinline - block: DT.() -> Unit = {}): HTMLElement = DT(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: DT.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return DT(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Emphasis */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.em(classes: String? = null, crossinline - block: EM.() -> Unit = {}): HTMLElement = EM(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: EM.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return EM(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Plugin */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.embed(classes: String? = null, crossinline - block: EMBED.() -> Unit = {}): HTMLEmbedElement = EMBED(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLEmbedElement + block: EMBED.() -> Unit = {}): HTMLEmbedElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return EMBED(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLEmbedElement +} /** * Form control group */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.fieldSet(classes: String? = null, crossinline - block: FIELDSET.() -> Unit = {}): HTMLFieldSetElement = FIELDSET(attributesMapOf("class", - classes), this) - .visitAndFinalize(this, block) as HTMLFieldSetElement + block: FIELDSET.() -> Unit = {}): HTMLFieldSetElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return FIELDSET(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLFieldSetElement +} /** * Caption for */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.figcaption(classes: String? = null, crossinline - block: FIGCAPTION.() -> Unit = {}): HTMLElement = FIGCAPTION(attributesMapOf("class", classes), - this) - .visitAndFinalize(this, block) + block: FIGCAPTION.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return FIGCAPTION(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Figure with optional caption */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.figure(classes: String? = null, crossinline - block: FIGURE.() -> Unit = {}): HTMLElement = FIGURE(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: FIGURE.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return FIGURE(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Footer for a page or section */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.footer(classes: String? = null, crossinline - block: FOOTER.() -> Unit = {}): HTMLElement = FOOTER(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: FOOTER.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return FOOTER(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Interactive form */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.form( action: String? = null, encType: FormEncType? = null, method: FormMethod? = null, classes: String? = null, crossinline block: FORM.() -> Unit = {}, -): HTMLFormElement = FORM(attributesMapOf("action", action,"enctype", - encType?.enumEncode(),"method", method?.enumEncode(),"class", classes), this) - .visitAndFinalize(this, block) as HTMLFormElement +): HTMLFormElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return FORM(attributesMapOf("action", action,"enctype", encType?.enumEncode(),"method", + method?.enumEncode(),"class", classes), this) + .visitAndFinalize(this, block) as HTMLFormElement +} /** * Heading */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.h1(classes: String? = null, crossinline - block: H1.() -> Unit = {}): HTMLHeadingElement = H1(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLHeadingElement + block: H1.() -> Unit = {}): HTMLHeadingElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return H1(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLHeadingElement +} /** * Heading */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.h2(classes: String? = null, crossinline - block: H2.() -> Unit = {}): HTMLHeadingElement = H2(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLHeadingElement + block: H2.() -> Unit = {}): HTMLHeadingElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return H2(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLHeadingElement +} /** * Heading */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.h3(classes: String? = null, crossinline - block: H3.() -> Unit = {}): HTMLHeadingElement = H3(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLHeadingElement + block: H3.() -> Unit = {}): HTMLHeadingElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return H3(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLHeadingElement +} /** * Heading */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.h4(classes: String? = null, crossinline - block: H4.() -> Unit = {}): HTMLHeadingElement = H4(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLHeadingElement + block: H4.() -> Unit = {}): HTMLHeadingElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return H4(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLHeadingElement +} /** * Heading */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.h5(classes: String? = null, crossinline - block: H5.() -> Unit = {}): HTMLHeadingElement = H5(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLHeadingElement + block: H5.() -> Unit = {}): HTMLHeadingElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return H5(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLHeadingElement +} /** * Heading */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.h6(classes: String? = null, crossinline - block: H6.() -> Unit = {}): HTMLHeadingElement = H6(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLHeadingElement + block: H6.() -> Unit = {}): HTMLHeadingElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return H6(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLHeadingElement +} /** * Document head @@ -599,30 +769,46 @@ public fun TagConsumer.head(content: String = ""): HTMLHeadElement * Document head */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.head(crossinline block: HEAD.() -> Unit = {}): - HTMLHeadElement = HEAD(emptyMap, this) - .visitAndFinalize(this, block) as HTMLHeadElement + HTMLHeadElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return HEAD(emptyMap, this) + .visitAndFinalize(this, block) as HTMLHeadElement +} /** * Introductory or navigational aids for a page or section */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.`header`(classes: String? = null, crossinline - block: HEADER.() -> Unit = {}): HTMLElement = HEADER(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: HEADER.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return HEADER(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.hGroup(classes: String? = null, crossinline - block: HGROUP.() -> Unit = {}): HTMLElement = HGROUP(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: HGROUP.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return HGROUP(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Horizontal rule */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.hr(classes: String? = null, crossinline - block: HR.() -> Unit = {}): HTMLHRElement = HR(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLHRElement + block: HR.() -> Unit = {}): HTMLHRElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return HR(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLHRElement +} /** * Document root element @@ -638,17 +824,25 @@ public fun TagConsumer.html(content: String = "", namespace: String * Document root element */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.html(namespace: String? = null, crossinline - block: HTML.() -> Unit = {}): HTMLHtmlElement = HTML(emptyMap, this, namespace) - .visitAndFinalize(this, block) as HTMLHtmlElement + block: HTML.() -> Unit = {}): HTMLHtmlElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return HTML(emptyMap, this, namespace) + .visitAndFinalize(this, block) as HTMLHtmlElement +} /** * Italic text style */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.i(classes: String? = null, crossinline - block: I.() -> Unit = {}): HTMLElement = I(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: I.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return I(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Inline subwindow @@ -665,31 +859,40 @@ public fun TagConsumer.iframe( * Inline subwindow */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.iframe( sandbox: IframeSandbox? = null, classes: String? = null, crossinline block: IFRAME.() -> Unit = {}, -): HTMLElement = IFRAME(attributesMapOf("sandbox", sandbox?.enumEncode(),"class", classes), this) - .visitAndFinalize(this, block) +): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return IFRAME(attributesMapOf("sandbox", sandbox?.enumEncode(),"class", classes), this) + .visitAndFinalize(this, block) +} /** * Embedded image */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.img( alt: String? = null, src: String? = null, loading: ImgLoading? = null, classes: String? = null, crossinline block: IMG.() -> Unit = {}, -): HTMLImageElement = IMG(attributesMapOf("alt", alt,"src", src,"loading", - loading?.enumEncode(),"class", classes), this) - .visitAndFinalize(this, block) as HTMLImageElement +): HTMLImageElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return IMG(attributesMapOf("alt", alt,"src", src,"loading", loading?.enumEncode(),"class", + classes), this) + .visitAndFinalize(this, block) as HTMLImageElement +} /** * Form control */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.input( type: InputType? = null, formEncType: InputFormEncType? = null, @@ -697,106 +900,152 @@ public inline fun TagConsumer.input( name: String? = null, classes: String? = null, crossinline block: INPUT.() -> Unit = {}, -): HTMLInputElement = INPUT(attributesMapOf("type", type?.enumEncode(),"formenctype", - formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), - this) - .visitAndFinalize(this, block) as HTMLInputElement +): HTMLInputElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return INPUT(attributesMapOf("type", type?.enumEncode(),"formenctype", + formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", + classes), this) + .visitAndFinalize(this, block) as HTMLInputElement +} /** * Inserted text */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.ins(classes: String? = null, crossinline - block: INS.() -> Unit = {}): HTMLElement = INS(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: INS.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return INS(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Text to be entered by the user */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.kbd(classes: String? = null, crossinline - block: KBD.() -> Unit = {}): HTMLElement = KBD(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: KBD.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return KBD(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Cryptographic key-pair generator form control */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.keyGen( keyType: KeyGenKeyType? = null, classes: String? = null, crossinline block: KEYGEN.() -> Unit = {}, -): HTMLElement = KEYGEN(attributesMapOf("keytype", keyType?.enumEncode(),"class", classes), this) - .visitAndFinalize(this, block) +): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return KEYGEN(attributesMapOf("keytype", keyType?.enumEncode(),"class", classes), this) + .visitAndFinalize(this, block) +} /** * Form field label text */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.label(classes: String? = null, crossinline - block: LABEL.() -> Unit = {}): HTMLLabelElement = LABEL(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLLabelElement + block: LABEL.() -> Unit = {}): HTMLLabelElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return LABEL(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLLabelElement +} /** * Fieldset legend */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.legend(classes: String? = null, crossinline - block: LEGEND.() -> Unit = {}): HTMLLegendElement = LEGEND(attributesMapOf("class", classes), - this) - .visitAndFinalize(this, block) as HTMLLegendElement + block: LEGEND.() -> Unit = {}): HTMLLegendElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return LEGEND(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLLegendElement +} /** * List item */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.li(classes: String? = null, crossinline - block: LI.() -> Unit = {}): HTMLLIElement = LI(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLLIElement + block: LI.() -> Unit = {}): HTMLLIElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return LI(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLLIElement +} /** * A media-independent link */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.link( href: String? = null, rel: String? = null, type: String? = null, crossinline block: LINK.() -> Unit = {}, -): HTMLLinkElement = LINK(attributesMapOf("href", href,"rel", rel,"type", type), this) - .visitAndFinalize(this, block) as HTMLLinkElement +): HTMLLinkElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return LINK(attributesMapOf("href", href,"rel", rel,"type", type), this) + .visitAndFinalize(this, block) as HTMLLinkElement +} /** * Container for the dominant contents of another element */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.main(classes: String? = null, crossinline - block: MAIN.() -> Unit = {}): HTMLElement = MAIN(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: MAIN.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return MAIN(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Client-side image map */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.map( name: String? = null, classes: String? = null, crossinline block: MAP.() -> Unit = {}, -): HTMLMapElement = MAP(attributesMapOf("name", name,"class", classes), this) - .visitAndFinalize(this, block) as HTMLMapElement +): HTMLMapElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return MAP(attributesMapOf("name", name,"class", classes), this) + .visitAndFinalize(this, block) as HTMLMapElement +} /** * Highlight */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.mark(classes: String? = null, crossinline - block: MARK.() -> Unit = {}): HTMLElement = MARK(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: MARK.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return MARK(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.math(classes: String? = null, crossinline - block: MATH.() -> Unit = {}): HTMLElement = MATH(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: MATH.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return MATH(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} @HtmlTagMarker public fun TagConsumer.mathml(classes: String? = null, content: String = ""): @@ -804,73 +1053,104 @@ public fun TagConsumer.mathml(classes: String? = null, content: Str .visitAndFinalize(this, {+content}) @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.mathml(classes: String? = null, crossinline - block: MATHML.() -> Unit = {}): HTMLElement = MATHML(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: MATHML.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return MATHML(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Generic metainformation */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.meta( name: String? = null, content: String? = null, charset: String? = null, crossinline block: META.() -> Unit = {}, -): HTMLMetaElement = META(attributesMapOf("name", name,"content", content,"charset", charset), this) - .visitAndFinalize(this, block) as HTMLMetaElement +): HTMLMetaElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return META(attributesMapOf("name", name,"content", content,"charset", charset), this) + .visitAndFinalize(this, block) as HTMLMetaElement +} /** * Gauge */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.meter(classes: String? = null, crossinline - block: METER.() -> Unit = {}): HTMLMeterElement = METER(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLMeterElement + block: METER.() -> Unit = {}): HTMLMeterElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return METER(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLMeterElement +} /** * Section with navigational links */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.nav(classes: String? = null, crossinline - block: NAV.() -> Unit = {}): HTMLElement = NAV(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: NAV.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return NAV(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Generic metainformation */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.noScript(classes: String? = null, crossinline - block: NOSCRIPT.() -> Unit = {}): HTMLElement = NOSCRIPT(attributesMapOf("class", classes), - this) - .visitAndFinalize(this, block) + block: NOSCRIPT.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return NOSCRIPT(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Generic embedded object */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.htmlObject(classes: String? = null, crossinline - block: OBJECT.() -> Unit = {}): HTMLElement = OBJECT(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: OBJECT.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return OBJECT(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Ordered list */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.ol(classes: String? = null, crossinline - block: OL.() -> Unit = {}): HTMLElement = OL(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: OL.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return OL(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Option group */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.optGroup( label: String? = null, classes: String? = null, crossinline block: OPTGROUP.() -> Unit = {}, -): HTMLOptGroupElement = OPTGROUP(attributesMapOf("label", label,"class", classes), this) - .visitAndFinalize(this, block) as HTMLOptGroupElement +): HTMLOptGroupElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return OPTGROUP(attributesMapOf("label", label,"class", classes), this) + .visitAndFinalize(this, block) as HTMLOptGroupElement +} /** * Selectable choice @@ -884,111 +1164,160 @@ public fun TagConsumer.option(classes: String? = null, content: Str * Selectable choice */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.option(classes: String? = null, crossinline - block: OPTION.() -> Unit = {}): HTMLOptionElement = OPTION(attributesMapOf("class", classes), - this) - .visitAndFinalize(this, block) as HTMLOptionElement + block: OPTION.() -> Unit = {}): HTMLOptionElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return OPTION(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLOptionElement +} /** * Calculated output value */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.output(classes: String? = null, crossinline - block: OUTPUT.() -> Unit = {}): HTMLOutputElement = OUTPUT(attributesMapOf("class", classes), - this) - .visitAndFinalize(this, block) as HTMLOutputElement + block: OUTPUT.() -> Unit = {}): HTMLOutputElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return OUTPUT(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLOutputElement +} /** * Paragraph */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.p(classes: String? = null, crossinline - block: P.() -> Unit = {}): HTMLParagraphElement = P(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLParagraphElement + block: P.() -> Unit = {}): HTMLParagraphElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return P(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLParagraphElement +} /** * Named property value */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.`param`( name: String? = null, `value`: String? = null, crossinline block: PARAM.() -> Unit = {}, -): HTMLParamElement = PARAM(attributesMapOf("name", name,"value", value), this) - .visitAndFinalize(this, block) as HTMLParamElement +): HTMLParamElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return PARAM(attributesMapOf("name", name,"value", value), this) + .visitAndFinalize(this, block) as HTMLParamElement +} /** * Pictures container */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.picture(crossinline block: PICTURE.() -> Unit = {}): - HTMLPictureElement = PICTURE(emptyMap, this) - .visitAndFinalize(this, block) as HTMLPictureElement + HTMLPictureElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return PICTURE(emptyMap, this) + .visitAndFinalize(this, block) as HTMLPictureElement +} /** * Preformatted text */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.pre(classes: String? = null, crossinline - block: PRE.() -> Unit = {}): HTMLPreElement = PRE(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLPreElement + block: PRE.() -> Unit = {}): HTMLPreElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return PRE(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLPreElement +} /** * Progress bar */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.progress(classes: String? = null, crossinline - block: PROGRESS.() -> Unit = {}): HTMLProgressElement = PROGRESS(attributesMapOf("class", - classes), this) - .visitAndFinalize(this, block) as HTMLProgressElement + block: PROGRESS.() -> Unit = {}): HTMLProgressElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return PROGRESS(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLProgressElement +} /** * Short inline quotation */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.q(classes: String? = null, crossinline - block: Q.() -> Unit = {}): HTMLElement = Q(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: Q.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return Q(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Parenthesis for ruby annotation text */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.rp(classes: String? = null, crossinline - block: RP.() -> Unit = {}): HTMLElement = RP(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: RP.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return RP(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Ruby annotation text */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.rt(classes: String? = null, crossinline - block: RT.() -> Unit = {}): HTMLElement = RT(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: RT.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return RT(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Ruby annotation(s) */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.ruby(classes: String? = null, crossinline - block: RUBY.() -> Unit = {}): HTMLElement = RUBY(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: RUBY.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return RUBY(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Strike-through text style */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.s(classes: String? = null, crossinline - block: S.() -> Unit = {}): HTMLElement = S(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: S.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return S(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Sample or quote text style */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.samp(classes: String? = null, crossinline - block: SAMP.() -> Unit = {}): HTMLElement = SAMP(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: SAMP.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return SAMP(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Script statements @@ -1009,69 +1338,99 @@ public fun TagConsumer.script( * Script statements */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.script( type: String? = null, src: String? = null, crossorigin: ScriptCrossorigin? = null, crossinline block: SCRIPT.() -> Unit = {}, -): HTMLScriptElement = SCRIPT(attributesMapOf("type", type,"src", src,"crossorigin", - crossorigin?.enumEncode()), this) - .visitAndFinalize(this, block) as HTMLScriptElement +): HTMLScriptElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return SCRIPT(attributesMapOf("type", type,"src", src,"crossorigin", crossorigin?.enumEncode()), + this) + .visitAndFinalize(this, block) as HTMLScriptElement +} /** * Generic document or application section */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.section(classes: String? = null, crossinline - block: SECTION.() -> Unit = {}): HTMLElement = SECTION(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: SECTION.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return SECTION(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Option selector */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.select(classes: String? = null, crossinline - block: SELECT.() -> Unit = {}): HTMLSelectElement = SELECT(attributesMapOf("class", classes), - this) - .visitAndFinalize(this, block) as HTMLSelectElement + block: SELECT.() -> Unit = {}): HTMLSelectElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return SELECT(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLSelectElement +} @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.slot(classes: String? = null, crossinline - block: SLOT.() -> Unit = {}): HTMLElement = SLOT(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: SLOT.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return SLOT(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Small text style */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.small(classes: String? = null, crossinline - block: SMALL.() -> Unit = {}): HTMLElement = SMALL(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: SMALL.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return SMALL(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Media source for */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.source(classes: String? = null, crossinline - block: SOURCE.() -> Unit = {}): HTMLSourceElement = SOURCE(attributesMapOf("class", classes), - this) - .visitAndFinalize(this, block) as HTMLSourceElement + block: SOURCE.() -> Unit = {}): HTMLSourceElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return SOURCE(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLSourceElement +} /** * Generic language/style container */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.span(classes: String? = null, crossinline - block: SPAN.() -> Unit = {}): HTMLSpanElement = SPAN(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLSpanElement + block: SPAN.() -> Unit = {}): HTMLSpanElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return SPAN(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLSpanElement +} /** * Strong emphasis */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.strong(classes: String? = null, crossinline - block: STRONG.() -> Unit = {}): HTMLElement = STRONG(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: STRONG.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return STRONG(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Style info @@ -1087,33 +1446,49 @@ public fun TagConsumer.style(type: String? = null, content: String * Style info */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.style(type: String? = null, crossinline - block: STYLE.() -> Unit = {}): HTMLStyleElement = STYLE(attributesMapOf("type", type), this) - .visitAndFinalize(this, block) as HTMLStyleElement + block: STYLE.() -> Unit = {}): HTMLStyleElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return STYLE(attributesMapOf("type", type), this) + .visitAndFinalize(this, block) as HTMLStyleElement +} /** * Subscript */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.sub(classes: String? = null, crossinline - block: SUB.() -> Unit = {}): HTMLElement = SUB(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: SUB.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return SUB(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Caption for */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.summary(classes: String? = null, crossinline - block: SUMMARY.() -> Unit = {}): HTMLElement = SUMMARY(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: SUMMARY.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return SUMMARY(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Superscript */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.sup(classes: String? = null, crossinline - block: SUP.() -> Unit = {}): HTMLElement = SUP(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: SUP.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return SUP(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} @HtmlTagMarker public fun TagConsumer.svg(classes: String? = null, content: String = ""): HTMLElement @@ -1121,43 +1496,61 @@ public fun TagConsumer.svg(classes: String? = null, content: String .visitAndFinalize(this, {+content}) @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.svg(classes: String? = null, crossinline - block: SVG.() -> Unit = {}): HTMLElement = SVG(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: SVG.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return SVG(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.table(classes: String? = null, crossinline - block: TABLE.() -> Unit = {}): HTMLTableElement = TABLE(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLTableElement + block: TABLE.() -> Unit = {}): HTMLTableElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return TABLE(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLTableElement +} /** * Table body */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.tbody(classes: String? = null, crossinline - block: TBODY.() -> Unit = {}): HTMLTableSectionElement = TBODY(attributesMapOf("class", - classes), this) - .visitAndFinalize(this, block) as HTMLTableSectionElement + block: TBODY.() -> Unit = {}): HTMLTableSectionElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return TBODY(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLTableSectionElement +} /** * Table data cell */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.td(classes: String? = null, crossinline - block: TD.() -> Unit = {}): HTMLTableCellElement = TD(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLTableCellElement + block: TD.() -> Unit = {}): HTMLTableCellElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return TD(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLTableCellElement +} /** * Template */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.template(classes: String? = null, crossinline - block: TEMPLATE.() -> Unit = {}): HTMLTemplateElement = TEMPLATE(attributesMapOf("class", - classes), this) - .visitAndFinalize(this, block) as HTMLTemplateElement + block: TEMPLATE.() -> Unit = {}): HTMLTemplateElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return TEMPLATE(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLTemplateElement +} /** * Multi-line text field @@ -1177,52 +1570,70 @@ public fun TagConsumer.textArea( * Multi-line text field */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.textArea( rows: String? = null, cols: String? = null, wrap: TextAreaWrap? = null, classes: String? = null, crossinline block: TEXTAREA.() -> Unit = {}, -): HTMLTextAreaElement = TEXTAREA(attributesMapOf("rows", rows,"cols", cols,"wrap", - wrap?.enumEncode(),"class", classes), this) - .visitAndFinalize(this, block) as HTMLTextAreaElement +): HTMLTextAreaElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return TEXTAREA(attributesMapOf("rows", rows,"cols", cols,"wrap", wrap?.enumEncode(),"class", + classes), this) + .visitAndFinalize(this, block) as HTMLTextAreaElement +} /** * Table footer */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.tfoot(classes: String? = null, crossinline - block: TFOOT.() -> Unit = {}): HTMLTableSectionElement = TFOOT(attributesMapOf("class", - classes), this) - .visitAndFinalize(this, block) as HTMLTableSectionElement + block: TFOOT.() -> Unit = {}): HTMLTableSectionElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return TFOOT(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLTableSectionElement +} /** * Table header cell */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.th( scope: ThScope? = null, classes: String? = null, crossinline block: TH.() -> Unit = {}, -): HTMLTableCellElement = TH(attributesMapOf("scope", scope?.enumEncode(),"class", classes), this) - .visitAndFinalize(this, block) as HTMLTableCellElement +): HTMLTableCellElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return TH(attributesMapOf("scope", scope?.enumEncode(),"class", classes), this) + .visitAndFinalize(this, block) as HTMLTableCellElement +} /** * Table header */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.thead(classes: String? = null, crossinline - block: THEAD.() -> Unit = {}): HTMLTableSectionElement = THEAD(attributesMapOf("class", - classes), this) - .visitAndFinalize(this, block) as HTMLTableSectionElement + block: THEAD.() -> Unit = {}): HTMLTableSectionElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return THEAD(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLTableSectionElement +} /** * Machine-readable equivalent of date- or time-related data */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.time(classes: String? = null, crossinline - block: TIME.() -> Unit = {}): HTMLTimeElement = TIME(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLTimeElement + block: TIME.() -> Unit = {}): HTMLTimeElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return TIME(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLTimeElement +} /** * Document title @@ -1236,46 +1647,70 @@ public fun TagConsumer.title(content: String = ""): HTMLTitleElemen * Document title */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.title(crossinline block: TITLE.() -> Unit = {}): - HTMLTitleElement = TITLE(emptyMap, this) - .visitAndFinalize(this, block) as HTMLTitleElement + HTMLTitleElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return TITLE(emptyMap, this) + .visitAndFinalize(this, block) as HTMLTitleElement +} /** * Table row */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.tr(classes: String? = null, crossinline - block: TR.() -> Unit = {}): HTMLTableRowElement = TR(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLTableRowElement + block: TR.() -> Unit = {}): HTMLTableRowElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return TR(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLTableRowElement +} /** * Underlined text style */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.u(classes: String? = null, crossinline - block: U.() -> Unit = {}): HTMLElement = U(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: U.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return U(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Unordered list */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.ul(classes: String? = null, crossinline - block: UL.() -> Unit = {}): HTMLElement = UL(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: UL.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return UL(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Unordered list */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.htmlVar(classes: String? = null, crossinline - block: VAR.() -> Unit = {}): HTMLElement = VAR(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: VAR.() -> Unit = {}): HTMLElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return VAR(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Video player */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.video(classes: String? = null, crossinline - block: VIDEO.() -> Unit = {}): HTMLVideoElement = VIDEO(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLVideoElement + block: VIDEO.() -> Unit = {}): HTMLVideoElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return VIDEO(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLVideoElement +} diff --git a/src/jsTest/kotlin/trees.kt b/src/jsTest/kotlin/trees.kt index dbae5441..88a7f498 100644 --- a/src/jsTest/kotlin/trees.kt +++ b/src/jsTest/kotlin/trees.kt @@ -1,12 +1,41 @@ package kotlinx.html.tests -import kotlinx.html.* -import kotlinx.html.consumers.* -import kotlinx.html.dom.* -import kotlinx.html.js.* -import org.w3c.dom.* -import kotlinx.browser.* -import kotlin.test.* +import kotlinx.browser.document +import kotlinx.html.Entities +import kotlinx.html.a +import kotlinx.html.classes +import kotlinx.html.consumers.trace +import kotlinx.html.div +import kotlinx.html.dom.append +import kotlinx.html.dom.create +import kotlinx.html.dom.prepend +import kotlinx.html.id +import kotlinx.html.js.col +import kotlinx.html.js.colGroup +import kotlinx.html.js.div +import kotlinx.html.js.form +import kotlinx.html.js.h1 +import kotlinx.html.js.onClickFunction +import kotlinx.html.js.onSubmitFunction +import kotlinx.html.js.p +import kotlinx.html.js.span +import kotlinx.html.js.svg +import kotlinx.html.js.td +import kotlinx.html.js.th +import kotlinx.html.li +import kotlinx.html.p +import kotlinx.html.span +import kotlinx.html.ul +import org.w3c.dom.Element +import org.w3c.dom.HTMLDivElement +import org.w3c.dom.HTMLElement +import org.w3c.dom.HTMLFormElement +import org.w3c.dom.asList +import org.w3c.dom.get +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertTrue +import kotlin.test.fail class DomTreeImplTest { @Test fun simpleTree() { @@ -231,15 +260,32 @@ class DomTreeImplTest { val wrapper = wrapper() wrapper.appendChild(document.createElement("A").apply { textContent = "aaa" }) + val pElement: Element wrapper.prepend { - p { + pElement = p { text("OK") } } + assertEquals("OK", pElement.textContent) assertEquals("

OK

aaa", wrapper.innerHTML) } + @Test fun testAppend() { + val wrapper = wrapper() + wrapper.appendChild(document.createElement("A").apply { textContent = "aaa" }) + + val pElement: Element + wrapper.append { + pElement = p { + text("OK") + } + } + + assertEquals("OK", pElement.textContent) + assertEquals("aaa

OK

", wrapper.innerHTML) + } + @Test fun testComment() { val wrapper = wrapper() wrapper.append.div { diff --git a/src/jvmMain/kotlin/dom-jvm.kt b/src/jvmMain/kotlin/dom-jvm.kt index c6440b10..b13b6e26 100644 --- a/src/jvmMain/kotlin/dom-jvm.kt +++ b/src/jvmMain/kotlin/dom-jvm.kt @@ -1,16 +1,28 @@ package kotlinx.html.dom -import kotlinx.html.* -import kotlinx.html.consumers.* +import kotlinx.html.Entities +import kotlinx.html.Tag +import kotlinx.html.TagConsumer +import kotlinx.html.Unsafe +import kotlinx.html.consumers.onFinalize +import kotlinx.html.consumers.onFinalizeMap import kotlinx.html.org.w3c.dom.events.Event -import org.w3c.dom.* -import org.xml.sax.* -import java.io.* -import java.util.* -import javax.xml.parsers.* -import javax.xml.transform.* -import javax.xml.transform.dom.* -import javax.xml.transform.stream.* +import org.w3c.dom.Document +import org.w3c.dom.Element +import org.w3c.dom.Node +import org.xml.sax.InputSource +import java.io.StringReader +import java.io.StringWriter +import java.io.Writer +import javax.xml.parsers.DocumentBuilder +import javax.xml.parsers.DocumentBuilderFactory +import javax.xml.transform.OutputKeys +import javax.xml.transform.TransformerFactory +import javax.xml.transform.dom.DOMSource +import javax.xml.transform.stream.StreamResult +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract class HTMLDOMBuilder(val document : Document) : TagConsumer { private val path = arrayListOf() @@ -95,7 +107,7 @@ class HTMLDOMBuilder(val document : Document) : TagConsumer { private val UnsafeImpl = object : Unsafe { override operator fun String.unaryPlus() { val element = documentBuilder - .parse(InputSource(StringReader("" + this + ""))) + .parse(InputSource(StringReader("$this"))) .documentElement val importNode = document.importNode(element, true) @@ -120,25 +132,30 @@ fun Document.createHTMLTree() : TagConsumer = HTMLDOMBuilder(this) val Document.create : TagConsumer get() = HTMLDOMBuilder(this) -fun Node.append(block : TagConsumer.() -> Unit) : List = ArrayList().let { result -> - ownerDocumentExt.createHTMLTree().onFinalize { it, partial -> - if (!partial) { - appendChild(it); result.add(it) - } - }.block() - - result +@OptIn(ExperimentalContracts::class) +fun Node.append(block : TagConsumer.() -> Unit) : List { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return buildList { + ownerDocumentExt.createHTMLTree().onFinalize { it, partial -> + if (!partial) { + appendChild(it) + add(it) + } + }.block() + } } -fun Node.prepend(block: TagConsumer.() -> Unit) : List = ArrayList().let { result -> - ownerDocumentExt.createHTMLTree().onFinalize { it, partial -> - if (!partial) { - insertBefore(it, firstChild) - result.add(it) - } - }.block() - - result +@OptIn(ExperimentalContracts::class) +fun Node.prepend(block: TagConsumer.() -> Unit) : List { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return buildList { + ownerDocumentExt.createHTMLTree().onFinalize { it, partial -> + if (!partial) { + insertBefore(it, firstChild) + add(it) + } + }.block() + } } val Node.append: TagConsumer @@ -159,9 +176,10 @@ fun createHTMLDocument() : TagConsumer = DocumentBuilderFactory.newIns document -> HTMLDOMBuilder(document).onFinalizeMap { it, partial -> if (!partial) {document.appendChild(it)}; document } } -inline fun document(block : Document.() -> Unit) : Document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument().let { document -> - document.block() - document +@OptIn(ExperimentalContracts::class) +inline fun document(block : Document.() -> Unit) : Document { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument().apply(block) } fun Writer.write(document : Document, prettyPrint : Boolean = true) : Writer { diff --git a/src/jvmTest/kotlin/dom-trees.kt b/src/jvmTest/kotlin/dom-trees.kt index a44de504..bbf267da 100644 --- a/src/jvmTest/kotlin/dom-trees.kt +++ b/src/jvmTest/kotlin/dom-trees.kt @@ -1,9 +1,34 @@ package kotlinx.html.tests -import kotlinx.html.* -import kotlinx.html.consumers.* -import kotlinx.html.dom.* -import kotlin.test.* +import kotlinx.html.Entities +import kotlinx.html.HtmlBlockTag +import kotlinx.html.HtmlHeadTag +import kotlinx.html.HtmlInlineTag +import kotlinx.html.ScriptType +import kotlinx.html.a +import kotlinx.html.body +import kotlinx.html.classes +import kotlinx.html.consumers.filter +import kotlinx.html.div +import kotlinx.html.dom.append +import kotlinx.html.dom.create +import kotlinx.html.dom.createHTMLDocument +import kotlinx.html.dom.document +import kotlinx.html.dom.prepend +import kotlinx.html.dom.serialize +import kotlinx.html.h1 +import kotlinx.html.head +import kotlinx.html.html +import kotlinx.html.id +import kotlinx.html.meta +import kotlinx.html.p +import kotlinx.html.script +import kotlinx.html.span +import kotlinx.html.svg +import kotlinx.html.unsafe +import org.w3c.dom.Element +import kotlin.test.Test +import kotlin.test.assertEquals class TestDOMTrees { @Test fun `able to create simple tree`() { @@ -84,8 +109,9 @@ class TestDOMTrees { val contentNode = document.getElementById("content")!! + val p1Element: Element val nodes = contentNode.append { - p { + p1Element = p { +"p1" } p { @@ -96,8 +122,8 @@ class TestDOMTrees { } } + assertEquals("p1", p1Element.textContent) assertEquals(2, nodes.size) - assertEquals(""" @@ -125,8 +151,9 @@ class TestDOMTrees { } @Test fun `svg should have namespace`() { + val htmlElement: Element val d = document { - append.html { + htmlElement = append.html { body { svg { } @@ -134,6 +161,7 @@ class TestDOMTrees { } } + assertEquals("", htmlElement.textContent) assertEquals("\n", d.serialize(false).trim().replace("\r\n", "\n")) } @@ -205,12 +233,14 @@ class TestDOMTrees { } } + val okElement: Element document.getElementsByTagName("body").item(0).prepend { - p { + okElement = p { text("OK") } } + assertEquals("OK", okElement.textContent) assertEquals("\n" + "

OK

aaa", document.serialize(false).trim().replace("\r\n", "\n")) diff --git a/src/wasmJsMain/kotlin/dom-js.kt b/src/wasmJsMain/kotlin/dom-js.kt index 0d2d73dc..f5ae9d13 100644 --- a/src/wasmJsMain/kotlin/dom-js.kt +++ b/src/wasmJsMain/kotlin/dom-js.kt @@ -12,8 +12,11 @@ import org.w3c.dom.Element import org.w3c.dom.HTMLElement import org.w3c.dom.Node import org.w3c.dom.asList +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract -private inline fun Element.setEvent(name: String, noinline callback: (Event) -> Unit): Unit { +private inline fun Element.setEvent(name: String, noinline callback: (Event) -> Unit) { val eventName = name.removePrefix("on") addEventListener(eventName, callback) } @@ -126,28 +129,31 @@ fun Document.createTree(): TagConsumer = JSDOMBuilder(this) val Document.create: TagConsumer get() = JSDOMBuilder(this) -fun Node.append(block: TagConsumer.() -> Unit): List = - ArrayList().let { result -> +@OptIn(ExperimentalContracts::class) +fun Node.append(block: TagConsumer.() -> Unit): List { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return buildList { ownerDocumentExt.createTree().onFinalize { it, partial -> if (!partial) { - result.add(it); appendChild(it) + add(it) + appendChild(it) } }.block() - - result } +} -fun Node.prepend(block: TagConsumer.() -> Unit): List = - ArrayList().let { result -> +@OptIn(ExperimentalContracts::class) +fun Node.prepend(block: TagConsumer.() -> Unit): List { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return buildList { ownerDocumentExt.createTree().onFinalize { it, partial -> if (!partial) { - result.add(it) + add(it) insertBefore(it, firstChild) } }.block() - - result } +} val Element.append: TagConsumer get() = ownerDocumentExt.createTree().onFinalize { element, partial -> diff --git a/src/wasmJsMain/kotlin/generated/gen-consumer-tags-wasm-js.kt b/src/wasmJsMain/kotlin/generated/gen-consumer-tags-wasm-js.kt index c7eb9138..99ccb9d6 100644 --- a/src/wasmJsMain/kotlin/generated/gen-consumer-tags-wasm-js.kt +++ b/src/wasmJsMain/kotlin/generated/gen-consumer-tags-wasm-js.kt @@ -4,6 +4,9 @@ *******************************************************************************/ package kotlinx.html.js +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract import kotlinx.html.* import kotlinx.html.attributes.* @@ -199,128 +202,183 @@ import org.w3c.dom.HTMLVideoElement * Anchor */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.a( href: String? = null, target: String? = null, classes: String? = null, crossinline block: A.() -> Unit = {}, -): HTMLAnchorElement = A(attributesMapOf("href", href,"target", target,"class", classes), this) - .visitAndFinalize(this, block) as HTMLAnchorElement +): HTMLAnchorElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return A(attributesMapOf("href", href,"target", target,"class", classes), this) + .visitAndFinalize(this, block) as HTMLAnchorElement +} /** * Abbreviated form (e.g., WWW, HTTP,etc.) */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.abbr(classes: String? = null, crossinline - block: ABBR.() -> Unit = {}): Element = ABBR(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: ABBR.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return ABBR(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Information on author */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.address(classes: String? = null, crossinline - block: ADDRESS.() -> Unit = {}): Element = ADDRESS(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: ADDRESS.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return ADDRESS(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Client-side image map area */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.area( shape: AreaShape? = null, alt: String? = null, classes: String? = null, crossinline block: AREA.() -> Unit = {}, -): HTMLAreaElement = AREA(attributesMapOf("Shape", shape?.enumEncode(),"alt", alt,"class", classes), - this) - .visitAndFinalize(this, block) as HTMLAreaElement +): HTMLAreaElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return AREA(attributesMapOf("Shape", shape?.enumEncode(),"alt", alt,"class", classes), this) + .visitAndFinalize(this, block) as HTMLAreaElement +} /** * Self-contained syndicatable or reusable composition */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.article(classes: String? = null, crossinline - block: ARTICLE.() -> Unit = {}): Element = ARTICLE(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: ARTICLE.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return ARTICLE(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Sidebar for tangentially related content */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.aside(classes: String? = null, crossinline - block: ASIDE.() -> Unit = {}): Element = ASIDE(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: ASIDE.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return ASIDE(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Audio player */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.audio(classes: String? = null, crossinline - block: AUDIO.() -> Unit = {}): HTMLAudioElement = AUDIO(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLAudioElement + block: AUDIO.() -> Unit = {}): HTMLAudioElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return AUDIO(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLAudioElement +} /** * Bold text style */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.b(classes: String? = null, crossinline block: B.() -> Unit = - {}): Element = B(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return B(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Document base URI */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.base(classes: String? = null, crossinline - block: BASE.() -> Unit = {}): HTMLBaseElement = BASE(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLBaseElement + block: BASE.() -> Unit = {}): HTMLBaseElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return BASE(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLBaseElement +} /** * Text directionality isolation */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.bdi(classes: String? = null, crossinline - block: BDI.() -> Unit = {}): Element = BDI(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: BDI.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return BDI(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * I18N BiDi over-ride */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.bdo(classes: String? = null, crossinline - block: BDO.() -> Unit = {}): Element = BDO(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: BDO.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return BDO(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Long quotation */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.blockQuote(classes: String? = null, crossinline - block: BLOCKQUOTE.() -> Unit = {}): Element = BLOCKQUOTE(attributesMapOf("class", classes), - this) - .visitAndFinalize(this, block) + block: BLOCKQUOTE.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return BLOCKQUOTE(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Document body */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.body(classes: String? = null, crossinline - block: BODY.() -> Unit = {}): HTMLBodyElement = BODY(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLBodyElement + block: BODY.() -> Unit = {}): HTMLBodyElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return BODY(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLBodyElement +} /** * Forced line break */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.br(classes: String? = null, crossinline block: BR.() -> Unit - = {}): HTMLBRElement = BR(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLBRElement + = {}): HTMLBRElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return BR(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLBRElement +} /** * Push button */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.button( formEncType: ButtonFormEncType? = null, formMethod: ButtonFormMethod? = null, @@ -328,9 +386,12 @@ public inline fun TagConsumer.button( type: ButtonType? = null, classes: String? = null, crossinline block: BUTTON.() -> Unit = {}, -): HTMLButtonElement = BUTTON(attributesMapOf("formenctype", formEncType?.enumEncode(),"formmethod", - formMethod?.enumEncode(),"name", name,"type", type?.enumEncode(),"class", classes), this) - .visitAndFinalize(this, block) as HTMLButtonElement +): HTMLButtonElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return BUTTON(attributesMapOf("formenctype", formEncType?.enumEncode(),"formmethod", + formMethod?.enumEncode(),"name", name,"type", type?.enumEncode(),"class", classes), this) + .visitAndFinalize(this, block) as HTMLButtonElement +} /** * Scriptable bitmap canvas @@ -344,246 +405,355 @@ public fun TagConsumer.canvas(classes: String? = null, content: String * Scriptable bitmap canvas */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.canvas(classes: String? = null, crossinline - block: CANVAS.() -> Unit = {}): HTMLCanvasElement = CANVAS(attributesMapOf("class", classes), - this) - .visitAndFinalize(this, block) as HTMLCanvasElement + block: CANVAS.() -> Unit = {}): HTMLCanvasElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return CANVAS(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLCanvasElement +} /** * Table caption */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.caption(classes: String? = null, crossinline - block: CAPTION.() -> Unit = {}): Element = CAPTION(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: CAPTION.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return CAPTION(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Citation */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.cite(classes: String? = null, crossinline - block: CITE.() -> Unit = {}): Element = CITE(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: CITE.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return CITE(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Computer code fragment */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.code(classes: String? = null, crossinline - block: CODE.() -> Unit = {}): Element = CODE(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: CODE.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return CODE(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Table column */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.col(classes: String? = null, crossinline - block: COL.() -> Unit = {}): HTMLTableColElement = COL(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLTableColElement + block: COL.() -> Unit = {}): HTMLTableColElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return COL(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLTableColElement +} /** * Table column group */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.colGroup(classes: String? = null, crossinline - block: COLGROUP.() -> Unit = {}): HTMLTableColElement = COLGROUP(attributesMapOf("class", - classes), this) - .visitAndFinalize(this, block) as HTMLTableColElement + block: COLGROUP.() -> Unit = {}): HTMLTableColElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return COLGROUP(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLTableColElement +} @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.command( type: CommandType? = null, classes: String? = null, crossinline block: COMMAND.() -> Unit = {}, -): Element = COMMAND(attributesMapOf("type", type?.enumEncode(),"class", classes), this) - .visitAndFinalize(this, block) +): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return COMMAND(attributesMapOf("type", type?.enumEncode(),"class", classes), this) + .visitAndFinalize(this, block) +} /** * Container for options for */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.dataList(classes: String? = null, crossinline - block: DATALIST.() -> Unit = {}): HTMLDataListElement = DATALIST(attributesMapOf("class", - classes), this) - .visitAndFinalize(this, block) as HTMLDataListElement + block: DATALIST.() -> Unit = {}): HTMLDataListElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return DATALIST(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLDataListElement +} /** * Definition description */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.dd(classes: String? = null, crossinline block: DD.() -> Unit - = {}): Element = DD(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return DD(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Deleted text */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.del(classes: String? = null, crossinline - block: DEL.() -> Unit = {}): Element = DEL(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: DEL.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return DEL(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Disclosure control for hiding details */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.details(classes: String? = null, crossinline - block: DETAILS.() -> Unit = {}): HTMLDetailsElement = DETAILS(attributesMapOf("class", classes), - this) - .visitAndFinalize(this, block) as HTMLDetailsElement + block: DETAILS.() -> Unit = {}): HTMLDetailsElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return DETAILS(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLDetailsElement +} /** * Instance definition */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.dfn(classes: String? = null, crossinline - block: DFN.() -> Unit = {}): Element = DFN(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: DFN.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return DFN(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Dialog box or window */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.dialog(classes: String? = null, crossinline - block: DIALOG.() -> Unit = {}): HTMLDialogElement = DIALOG(attributesMapOf("class", classes), - this) - .visitAndFinalize(this, block) as HTMLDialogElement + block: DIALOG.() -> Unit = {}): HTMLDialogElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return DIALOG(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLDialogElement +} /** * Generic language/style container */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.div(classes: String? = null, crossinline - block: DIV.() -> Unit = {}): HTMLDivElement = DIV(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLDivElement + block: DIV.() -> Unit = {}): HTMLDivElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return DIV(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLDivElement +} /** * Definition list */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.dl(classes: String? = null, crossinline block: DL.() -> Unit - = {}): Element = DL(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return DL(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Definition term */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.dt(classes: String? = null, crossinline block: DT.() -> Unit - = {}): Element = DT(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return DT(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Emphasis */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.em(classes: String? = null, crossinline block: EM.() -> Unit - = {}): Element = EM(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return EM(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Plugin */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.embed(classes: String? = null, crossinline - block: EMBED.() -> Unit = {}): HTMLEmbedElement = EMBED(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLEmbedElement + block: EMBED.() -> Unit = {}): HTMLEmbedElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return EMBED(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLEmbedElement +} /** * Form control group */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.fieldSet(classes: String? = null, crossinline - block: FIELDSET.() -> Unit = {}): HTMLFieldSetElement = FIELDSET(attributesMapOf("class", - classes), this) - .visitAndFinalize(this, block) as HTMLFieldSetElement + block: FIELDSET.() -> Unit = {}): HTMLFieldSetElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return FIELDSET(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLFieldSetElement +} /** * Caption for */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.figcaption(classes: String? = null, crossinline - block: FIGCAPTION.() -> Unit = {}): Element = FIGCAPTION(attributesMapOf("class", classes), - this) - .visitAndFinalize(this, block) + block: FIGCAPTION.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return FIGCAPTION(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Figure with optional caption */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.figure(classes: String? = null, crossinline - block: FIGURE.() -> Unit = {}): Element = FIGURE(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: FIGURE.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return FIGURE(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Footer for a page or section */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.footer(classes: String? = null, crossinline - block: FOOTER.() -> Unit = {}): Element = FOOTER(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: FOOTER.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return FOOTER(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Interactive form */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.form( action: String? = null, encType: FormEncType? = null, method: FormMethod? = null, classes: String? = null, crossinline block: FORM.() -> Unit = {}, -): HTMLFormElement = FORM(attributesMapOf("action", action,"enctype", - encType?.enumEncode(),"method", method?.enumEncode(),"class", classes), this) - .visitAndFinalize(this, block) as HTMLFormElement +): HTMLFormElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return FORM(attributesMapOf("action", action,"enctype", encType?.enumEncode(),"method", + method?.enumEncode(),"class", classes), this) + .visitAndFinalize(this, block) as HTMLFormElement +} /** * Heading */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.h1(classes: String? = null, crossinline block: H1.() -> Unit - = {}): HTMLHeadingElement = H1(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLHeadingElement + = {}): HTMLHeadingElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return H1(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLHeadingElement +} /** * Heading */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.h2(classes: String? = null, crossinline block: H2.() -> Unit - = {}): HTMLHeadingElement = H2(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLHeadingElement + = {}): HTMLHeadingElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return H2(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLHeadingElement +} /** * Heading */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.h3(classes: String? = null, crossinline block: H3.() -> Unit - = {}): HTMLHeadingElement = H3(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLHeadingElement + = {}): HTMLHeadingElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return H3(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLHeadingElement +} /** * Heading */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.h4(classes: String? = null, crossinline block: H4.() -> Unit - = {}): HTMLHeadingElement = H4(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLHeadingElement + = {}): HTMLHeadingElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return H4(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLHeadingElement +} /** * Heading */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.h5(classes: String? = null, crossinline block: H5.() -> Unit - = {}): HTMLHeadingElement = H5(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLHeadingElement + = {}): HTMLHeadingElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return H5(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLHeadingElement +} /** * Heading */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.h6(classes: String? = null, crossinline block: H6.() -> Unit - = {}): HTMLHeadingElement = H6(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLHeadingElement + = {}): HTMLHeadingElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return H6(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLHeadingElement +} /** * Document head @@ -598,30 +768,46 @@ public fun TagConsumer.head(content: String = ""): HTMLHeadElement = HE * Document head */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.head(crossinline block: HEAD.() -> Unit = {}): - HTMLHeadElement = HEAD(emptyMap, this) - .visitAndFinalize(this, block) as HTMLHeadElement + HTMLHeadElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return HEAD(emptyMap, this) + .visitAndFinalize(this, block) as HTMLHeadElement +} /** * Introductory or navigational aids for a page or section */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.`header`(classes: String? = null, crossinline - block: HEADER.() -> Unit = {}): Element = HEADER(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: HEADER.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return HEADER(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.hGroup(classes: String? = null, crossinline - block: HGROUP.() -> Unit = {}): Element = HGROUP(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: HGROUP.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return HGROUP(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Horizontal rule */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.hr(classes: String? = null, crossinline block: HR.() -> Unit - = {}): HTMLHRElement = HR(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLHRElement + = {}): HTMLHRElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return HR(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLHRElement +} /** * Document root element @@ -637,17 +823,25 @@ public fun TagConsumer.html(content: String = "", namespace: String? = * Document root element */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.html(namespace: String? = null, crossinline - block: HTML.() -> Unit = {}): HTMLHtmlElement = HTML(emptyMap, this, namespace) - .visitAndFinalize(this, block) as HTMLHtmlElement + block: HTML.() -> Unit = {}): HTMLHtmlElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return HTML(emptyMap, this, namespace) + .visitAndFinalize(this, block) as HTMLHtmlElement +} /** * Italic text style */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.i(classes: String? = null, crossinline block: I.() -> Unit = - {}): Element = I(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return I(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Inline subwindow @@ -664,31 +858,40 @@ public fun TagConsumer.iframe( * Inline subwindow */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.iframe( sandbox: IframeSandbox? = null, classes: String? = null, crossinline block: IFRAME.() -> Unit = {}, -): Element = IFRAME(attributesMapOf("sandbox", sandbox?.enumEncode(),"class", classes), this) - .visitAndFinalize(this, block) +): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return IFRAME(attributesMapOf("sandbox", sandbox?.enumEncode(),"class", classes), this) + .visitAndFinalize(this, block) +} /** * Embedded image */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.img( alt: String? = null, src: String? = null, loading: ImgLoading? = null, classes: String? = null, crossinline block: IMG.() -> Unit = {}, -): HTMLImageElement = IMG(attributesMapOf("alt", alt,"src", src,"loading", - loading?.enumEncode(),"class", classes), this) - .visitAndFinalize(this, block) as HTMLImageElement +): HTMLImageElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return IMG(attributesMapOf("alt", alt,"src", src,"loading", loading?.enumEncode(),"class", + classes), this) + .visitAndFinalize(this, block) as HTMLImageElement +} /** * Form control */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.input( type: InputType? = null, formEncType: InputFormEncType? = null, @@ -696,106 +899,152 @@ public inline fun TagConsumer.input( name: String? = null, classes: String? = null, crossinline block: INPUT.() -> Unit = {}, -): HTMLInputElement = INPUT(attributesMapOf("type", type?.enumEncode(),"formenctype", - formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", classes), - this) - .visitAndFinalize(this, block) as HTMLInputElement +): HTMLInputElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return INPUT(attributesMapOf("type", type?.enumEncode(),"formenctype", + formEncType?.enumEncode(),"formmethod", formMethod?.enumEncode(),"name", name,"class", + classes), this) + .visitAndFinalize(this, block) as HTMLInputElement +} /** * Inserted text */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.ins(classes: String? = null, crossinline - block: INS.() -> Unit = {}): Element = INS(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: INS.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return INS(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Text to be entered by the user */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.kbd(classes: String? = null, crossinline - block: KBD.() -> Unit = {}): Element = KBD(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: KBD.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return KBD(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Cryptographic key-pair generator form control */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.keyGen( keyType: KeyGenKeyType? = null, classes: String? = null, crossinline block: KEYGEN.() -> Unit = {}, -): Element = KEYGEN(attributesMapOf("keytype", keyType?.enumEncode(),"class", classes), this) - .visitAndFinalize(this, block) +): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return KEYGEN(attributesMapOf("keytype", keyType?.enumEncode(),"class", classes), this) + .visitAndFinalize(this, block) +} /** * Form field label text */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.label(classes: String? = null, crossinline - block: LABEL.() -> Unit = {}): HTMLLabelElement = LABEL(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLLabelElement + block: LABEL.() -> Unit = {}): HTMLLabelElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return LABEL(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLLabelElement +} /** * Fieldset legend */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.legend(classes: String? = null, crossinline - block: LEGEND.() -> Unit = {}): HTMLLegendElement = LEGEND(attributesMapOf("class", classes), - this) - .visitAndFinalize(this, block) as HTMLLegendElement + block: LEGEND.() -> Unit = {}): HTMLLegendElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return LEGEND(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLLegendElement +} /** * List item */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.li(classes: String? = null, crossinline block: LI.() -> Unit - = {}): HTMLLIElement = LI(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLLIElement + = {}): HTMLLIElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return LI(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLLIElement +} /** * A media-independent link */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.link( href: String? = null, rel: String? = null, type: String? = null, crossinline block: LINK.() -> Unit = {}, -): HTMLLinkElement = LINK(attributesMapOf("href", href,"rel", rel,"type", type), this) - .visitAndFinalize(this, block) as HTMLLinkElement +): HTMLLinkElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return LINK(attributesMapOf("href", href,"rel", rel,"type", type), this) + .visitAndFinalize(this, block) as HTMLLinkElement +} /** * Container for the dominant contents of another element */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.main(classes: String? = null, crossinline - block: MAIN.() -> Unit = {}): Element = MAIN(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: MAIN.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return MAIN(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Client-side image map */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.map( name: String? = null, classes: String? = null, crossinline block: MAP.() -> Unit = {}, -): HTMLMapElement = MAP(attributesMapOf("name", name,"class", classes), this) - .visitAndFinalize(this, block) as HTMLMapElement +): HTMLMapElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return MAP(attributesMapOf("name", name,"class", classes), this) + .visitAndFinalize(this, block) as HTMLMapElement +} /** * Highlight */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.mark(classes: String? = null, crossinline - block: MARK.() -> Unit = {}): Element = MARK(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: MARK.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return MARK(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.math(classes: String? = null, crossinline - block: MATH.() -> Unit = {}): Element = MATH(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: MATH.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return MATH(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} @HtmlTagMarker public fun TagConsumer.mathml(classes: String? = null, content: String = ""): Element = @@ -803,72 +1052,104 @@ public fun TagConsumer.mathml(classes: String? = null, content: String .visitAndFinalize(this, {+content}) @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.mathml(classes: String? = null, crossinline - block: MATHML.() -> Unit = {}): Element = MATHML(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: MATHML.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return MATHML(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Generic metainformation */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.meta( name: String? = null, content: String? = null, charset: String? = null, crossinline block: META.() -> Unit = {}, -): HTMLMetaElement = META(attributesMapOf("name", name,"content", content,"charset", charset), this) - .visitAndFinalize(this, block) as HTMLMetaElement +): HTMLMetaElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return META(attributesMapOf("name", name,"content", content,"charset", charset), this) + .visitAndFinalize(this, block) as HTMLMetaElement +} /** * Gauge */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.meter(classes: String? = null, crossinline - block: METER.() -> Unit = {}): HTMLMeterElement = METER(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLMeterElement + block: METER.() -> Unit = {}): HTMLMeterElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return METER(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLMeterElement +} /** * Section with navigational links */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.nav(classes: String? = null, crossinline - block: NAV.() -> Unit = {}): Element = NAV(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: NAV.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return NAV(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Generic metainformation */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.noScript(classes: String? = null, crossinline - block: NOSCRIPT.() -> Unit = {}): Element = NOSCRIPT(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: NOSCRIPT.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return NOSCRIPT(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Generic embedded object */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.htmlObject(classes: String? = null, crossinline - block: OBJECT.() -> Unit = {}): Element = OBJECT(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: OBJECT.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return OBJECT(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Ordered list */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.ol(classes: String? = null, crossinline block: OL.() -> Unit - = {}): Element = OL(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return OL(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Option group */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.optGroup( label: String? = null, classes: String? = null, crossinline block: OPTGROUP.() -> Unit = {}, -): HTMLOptGroupElement = OPTGROUP(attributesMapOf("label", label,"class", classes), this) - .visitAndFinalize(this, block) as HTMLOptGroupElement +): HTMLOptGroupElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return OPTGROUP(attributesMapOf("label", label,"class", classes), this) + .visitAndFinalize(this, block) as HTMLOptGroupElement +} /** * Selectable choice @@ -882,111 +1163,160 @@ public fun TagConsumer.option(classes: String? = null, content: String * Selectable choice */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.option(classes: String? = null, crossinline - block: OPTION.() -> Unit = {}): HTMLOptionElement = OPTION(attributesMapOf("class", classes), - this) - .visitAndFinalize(this, block) as HTMLOptionElement + block: OPTION.() -> Unit = {}): HTMLOptionElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return OPTION(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLOptionElement +} /** * Calculated output value */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.output(classes: String? = null, crossinline - block: OUTPUT.() -> Unit = {}): HTMLOutputElement = OUTPUT(attributesMapOf("class", classes), - this) - .visitAndFinalize(this, block) as HTMLOutputElement + block: OUTPUT.() -> Unit = {}): HTMLOutputElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return OUTPUT(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLOutputElement +} /** * Paragraph */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.p(classes: String? = null, crossinline block: P.() -> Unit = - {}): HTMLParagraphElement = P(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLParagraphElement + {}): HTMLParagraphElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return P(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLParagraphElement +} /** * Named property value */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.`param`( name: String? = null, `value`: String? = null, crossinline block: PARAM.() -> Unit = {}, -): HTMLParamElement = PARAM(attributesMapOf("name", name,"value", value), this) - .visitAndFinalize(this, block) as HTMLParamElement +): HTMLParamElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return PARAM(attributesMapOf("name", name,"value", value), this) + .visitAndFinalize(this, block) as HTMLParamElement +} /** * Pictures container */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.picture(crossinline block: PICTURE.() -> Unit = {}): - HTMLPictureElement = PICTURE(emptyMap, this) - .visitAndFinalize(this, block) as HTMLPictureElement + HTMLPictureElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return PICTURE(emptyMap, this) + .visitAndFinalize(this, block) as HTMLPictureElement +} /** * Preformatted text */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.pre(classes: String? = null, crossinline - block: PRE.() -> Unit = {}): HTMLPreElement = PRE(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLPreElement + block: PRE.() -> Unit = {}): HTMLPreElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return PRE(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLPreElement +} /** * Progress bar */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.progress(classes: String? = null, crossinline - block: PROGRESS.() -> Unit = {}): HTMLProgressElement = PROGRESS(attributesMapOf("class", - classes), this) - .visitAndFinalize(this, block) as HTMLProgressElement + block: PROGRESS.() -> Unit = {}): HTMLProgressElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return PROGRESS(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLProgressElement +} /** * Short inline quotation */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.q(classes: String? = null, crossinline block: Q.() -> Unit = - {}): Element = Q(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return Q(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Parenthesis for ruby annotation text */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.rp(classes: String? = null, crossinline block: RP.() -> Unit - = {}): Element = RP(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return RP(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Ruby annotation text */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.rt(classes: String? = null, crossinline block: RT.() -> Unit - = {}): Element = RT(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return RT(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Ruby annotation(s) */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.ruby(classes: String? = null, crossinline - block: RUBY.() -> Unit = {}): Element = RUBY(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: RUBY.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return RUBY(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Strike-through text style */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.s(classes: String? = null, crossinline block: S.() -> Unit = - {}): Element = S(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return S(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Sample or quote text style */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.samp(classes: String? = null, crossinline - block: SAMP.() -> Unit = {}): Element = SAMP(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: SAMP.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return SAMP(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Script statements @@ -1007,69 +1337,99 @@ public fun TagConsumer.script( * Script statements */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.script( type: String? = null, src: String? = null, crossorigin: ScriptCrossorigin? = null, crossinline block: SCRIPT.() -> Unit = {}, -): HTMLScriptElement = SCRIPT(attributesMapOf("type", type,"src", src,"crossorigin", - crossorigin?.enumEncode()), this) - .visitAndFinalize(this, block) as HTMLScriptElement +): HTMLScriptElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return SCRIPT(attributesMapOf("type", type,"src", src,"crossorigin", crossorigin?.enumEncode()), + this) + .visitAndFinalize(this, block) as HTMLScriptElement +} /** * Generic document or application section */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.section(classes: String? = null, crossinline - block: SECTION.() -> Unit = {}): Element = SECTION(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: SECTION.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return SECTION(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Option selector */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.select(classes: String? = null, crossinline - block: SELECT.() -> Unit = {}): HTMLSelectElement = SELECT(attributesMapOf("class", classes), - this) - .visitAndFinalize(this, block) as HTMLSelectElement + block: SELECT.() -> Unit = {}): HTMLSelectElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return SELECT(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLSelectElement +} @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.slot(classes: String? = null, crossinline - block: SLOT.() -> Unit = {}): Element = SLOT(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: SLOT.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return SLOT(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Small text style */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.small(classes: String? = null, crossinline - block: SMALL.() -> Unit = {}): Element = SMALL(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: SMALL.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return SMALL(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Media source for */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.source(classes: String? = null, crossinline - block: SOURCE.() -> Unit = {}): HTMLSourceElement = SOURCE(attributesMapOf("class", classes), - this) - .visitAndFinalize(this, block) as HTMLSourceElement + block: SOURCE.() -> Unit = {}): HTMLSourceElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return SOURCE(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLSourceElement +} /** * Generic language/style container */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.span(classes: String? = null, crossinline - block: SPAN.() -> Unit = {}): HTMLSpanElement = SPAN(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLSpanElement + block: SPAN.() -> Unit = {}): HTMLSpanElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return SPAN(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLSpanElement +} /** * Strong emphasis */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.strong(classes: String? = null, crossinline - block: STRONG.() -> Unit = {}): Element = STRONG(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: STRONG.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return STRONG(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Style info @@ -1085,33 +1445,49 @@ public fun TagConsumer.style(type: String? = null, content: String = "" * Style info */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.style(type: String? = null, crossinline - block: STYLE.() -> Unit = {}): HTMLStyleElement = STYLE(attributesMapOf("type", type), this) - .visitAndFinalize(this, block) as HTMLStyleElement + block: STYLE.() -> Unit = {}): HTMLStyleElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return STYLE(attributesMapOf("type", type), this) + .visitAndFinalize(this, block) as HTMLStyleElement +} /** * Subscript */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.sub(classes: String? = null, crossinline - block: SUB.() -> Unit = {}): Element = SUB(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: SUB.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return SUB(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Caption for */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.summary(classes: String? = null, crossinline - block: SUMMARY.() -> Unit = {}): Element = SUMMARY(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: SUMMARY.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return SUMMARY(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Superscript */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.sup(classes: String? = null, crossinline - block: SUP.() -> Unit = {}): Element = SUP(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: SUP.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return SUP(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} @HtmlTagMarker public fun TagConsumer.svg(classes: String? = null, content: String = ""): Element = @@ -1119,43 +1495,61 @@ public fun TagConsumer.svg(classes: String? = null, content: String = " .visitAndFinalize(this, {+content}) @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.svg(classes: String? = null, crossinline - block: SVG.() -> Unit = {}): Element = SVG(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: SVG.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return SVG(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.table(classes: String? = null, crossinline - block: TABLE.() -> Unit = {}): HTMLTableElement = TABLE(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLTableElement + block: TABLE.() -> Unit = {}): HTMLTableElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return TABLE(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLTableElement +} /** * Table body */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.tbody(classes: String? = null, crossinline - block: TBODY.() -> Unit = {}): HTMLTableSectionElement = TBODY(attributesMapOf("class", - classes), this) - .visitAndFinalize(this, block) as HTMLTableSectionElement + block: TBODY.() -> Unit = {}): HTMLTableSectionElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return TBODY(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLTableSectionElement +} /** * Table data cell */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.td(classes: String? = null, crossinline block: TD.() -> Unit - = {}): HTMLTableCellElement = TD(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLTableCellElement + = {}): HTMLTableCellElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return TD(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLTableCellElement +} /** * Template */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.template(classes: String? = null, crossinline - block: TEMPLATE.() -> Unit = {}): HTMLTemplateElement = TEMPLATE(attributesMapOf("class", - classes), this) - .visitAndFinalize(this, block) as HTMLTemplateElement + block: TEMPLATE.() -> Unit = {}): HTMLTemplateElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return TEMPLATE(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLTemplateElement +} /** * Multi-line text field @@ -1175,52 +1569,70 @@ public fun TagConsumer.textArea( * Multi-line text field */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.textArea( rows: String? = null, cols: String? = null, wrap: TextAreaWrap? = null, classes: String? = null, crossinline block: TEXTAREA.() -> Unit = {}, -): HTMLTextAreaElement = TEXTAREA(attributesMapOf("rows", rows,"cols", cols,"wrap", - wrap?.enumEncode(),"class", classes), this) - .visitAndFinalize(this, block) as HTMLTextAreaElement +): HTMLTextAreaElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return TEXTAREA(attributesMapOf("rows", rows,"cols", cols,"wrap", wrap?.enumEncode(),"class", + classes), this) + .visitAndFinalize(this, block) as HTMLTextAreaElement +} /** * Table footer */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.tfoot(classes: String? = null, crossinline - block: TFOOT.() -> Unit = {}): HTMLTableSectionElement = TFOOT(attributesMapOf("class", - classes), this) - .visitAndFinalize(this, block) as HTMLTableSectionElement + block: TFOOT.() -> Unit = {}): HTMLTableSectionElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return TFOOT(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLTableSectionElement +} /** * Table header cell */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.th( scope: ThScope? = null, classes: String? = null, crossinline block: TH.() -> Unit = {}, -): HTMLTableCellElement = TH(attributesMapOf("scope", scope?.enumEncode(),"class", classes), this) - .visitAndFinalize(this, block) as HTMLTableCellElement +): HTMLTableCellElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return TH(attributesMapOf("scope", scope?.enumEncode(),"class", classes), this) + .visitAndFinalize(this, block) as HTMLTableCellElement +} /** * Table header */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.thead(classes: String? = null, crossinline - block: THEAD.() -> Unit = {}): HTMLTableSectionElement = THEAD(attributesMapOf("class", - classes), this) - .visitAndFinalize(this, block) as HTMLTableSectionElement + block: THEAD.() -> Unit = {}): HTMLTableSectionElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return THEAD(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLTableSectionElement +} /** * Machine-readable equivalent of date- or time-related data */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.time(classes: String? = null, crossinline - block: TIME.() -> Unit = {}): HTMLTimeElement = TIME(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLTimeElement + block: TIME.() -> Unit = {}): HTMLTimeElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return TIME(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLTimeElement +} /** * Document title @@ -1234,46 +1646,70 @@ public fun TagConsumer.title(content: String = ""): HTMLTitleElement = * Document title */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.title(crossinline block: TITLE.() -> Unit = {}): - HTMLTitleElement = TITLE(emptyMap, this) - .visitAndFinalize(this, block) as HTMLTitleElement + HTMLTitleElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return TITLE(emptyMap, this) + .visitAndFinalize(this, block) as HTMLTitleElement +} /** * Table row */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.tr(classes: String? = null, crossinline block: TR.() -> Unit - = {}): HTMLTableRowElement = TR(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLTableRowElement + = {}): HTMLTableRowElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return TR(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLTableRowElement +} /** * Underlined text style */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.u(classes: String? = null, crossinline block: U.() -> Unit = - {}): Element = U(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return U(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Unordered list */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.ul(classes: String? = null, crossinline block: UL.() -> Unit - = {}): Element = UL(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return UL(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Unordered list */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.htmlVar(classes: String? = null, crossinline - block: VAR.() -> Unit = {}): Element = VAR(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) + block: VAR.() -> Unit = {}): Element { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return VAR(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) +} /** * Video player */ @HtmlTagMarker +@OptIn(ExperimentalContracts::class) public inline fun TagConsumer.video(classes: String? = null, crossinline - block: VIDEO.() -> Unit = {}): HTMLVideoElement = VIDEO(attributesMapOf("class", classes), this) - .visitAndFinalize(this, block) as HTMLVideoElement + block: VIDEO.() -> Unit = {}): HTMLVideoElement { + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + return VIDEO(attributesMapOf("class", classes), this) + .visitAndFinalize(this, block) as HTMLVideoElement +} diff --git a/src/wasmJsTest/kotlin/trees.kt b/src/wasmJsTest/kotlin/trees.kt index d9413826..a1028334 100644 --- a/src/wasmJsTest/kotlin/trees.kt +++ b/src/wasmJsTest/kotlin/trees.kt @@ -25,13 +25,17 @@ import kotlinx.html.li import kotlinx.html.p import kotlinx.html.span import kotlinx.html.ul +import org.w3c.dom.Element import org.w3c.dom.HTMLDivElement import org.w3c.dom.HTMLElement import org.w3c.dom.HTMLFormElement import org.w3c.dom.asList import org.w3c.dom.get import org.w3c.dom.svg.SVGElement -import kotlin.test.* +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertTrue +import kotlin.test.fail class DomTreeImplTest { @Test fun simpleTree() { @@ -257,15 +261,32 @@ class DomTreeImplTest { val wrapper = wrapper() wrapper.appendChild(document.createElement("A").apply { textContent = "aaa" }) + val pElement: Element wrapper.prepend { - p { + pElement = p { text("OK") } } + assertEquals("OK", pElement.textContent) assertEquals("

OK

aaa", wrapper.innerHTML) } + @Test fun testAppend() { + val wrapper = wrapper() + wrapper.appendChild(document.createElement("A").apply { textContent = "aaa" }) + + val pElement: Element + wrapper.append() { + pElement = p { + text("OK") + } + } + + assertEquals("OK", pElement.textContent) + assertEquals("aaa

OK

", wrapper.innerHTML) + } + @Test fun testComment() { val wrapper = wrapper() wrapper.append.div { @@ -276,7 +297,5 @@ class DomTreeImplTest { } private fun wrapper() = document.body!!.append.div {} - @Suppress("UNCHECKED_CAST") - private fun uninitialized(): T = null as T private fun String.trimLines() = trimIndent().lines().filter { it.isNotBlank() }.joinToString("") }