[stdlib] Explicit visibility and return types: DOM API
This commit is contained in:
committed by
Space Team
parent
ce427b96b3
commit
4d8cf4903c
@@ -10,6 +10,7 @@ val jsStdlibSources = "${projectDir}/../stdlib/js/src"
|
||||
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
kotlin {
|
||||
explicitApi()
|
||||
js {
|
||||
sourceSets {
|
||||
val main by getting {
|
||||
|
||||
@@ -18,7 +18,7 @@ import kotlinx.dom.removeClass as newRemoveClass
|
||||
replaceWith = ReplaceWith("this.hasClass(cssClass)", "kotlinx.dom.hasClass")
|
||||
)
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.6")
|
||||
inline fun Element.hasClass(cssClass: String): Boolean = this.newHasClass(cssClass)
|
||||
public inline fun Element.hasClass(cssClass: String): Boolean = this.newHasClass(cssClass)
|
||||
|
||||
/**
|
||||
* Adds CSS class to element. Has no effect if all specified classes are already in class attribute of the element
|
||||
@@ -31,7 +31,7 @@ inline fun Element.hasClass(cssClass: String): Boolean = this.newHasClass(cssCla
|
||||
replaceWith = ReplaceWith("this.addClass(cssClasses)", "kotlinx.dom.addClass")
|
||||
)
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.6")
|
||||
inline fun Element.addClass(vararg cssClasses: String): Boolean = this.newAddClass(*cssClasses)
|
||||
public inline fun Element.addClass(vararg cssClasses: String): Boolean = this.newAddClass(*cssClasses)
|
||||
|
||||
/**
|
||||
* Removes all [cssClasses] from element. Has no effect if all specified classes are missing in class attribute of the element
|
||||
@@ -44,4 +44,4 @@ inline fun Element.addClass(vararg cssClasses: String): Boolean = this.newAddCla
|
||||
replaceWith = ReplaceWith("this.removeClass(cssClasses)", "kotlinx.dom.removeClass")
|
||||
)
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.6")
|
||||
inline fun Element.removeClass(vararg cssClasses: String): Boolean = this.newRemoveClass(*cssClasses)
|
||||
public inline fun Element.removeClass(vararg cssClasses: String): Boolean = this.newRemoveClass(*cssClasses)
|
||||
@@ -18,7 +18,7 @@ import kotlinx.dom.clear as newClear
|
||||
replaceWith = ReplaceWith("this.clear()", "kotlinx.dom.clear")
|
||||
)
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.6")
|
||||
public inline fun Node.clear() = this.newClear()
|
||||
public inline fun Node.clear(): Unit = this.newClear()
|
||||
|
||||
/**
|
||||
* Creates text node and append it to the element.
|
||||
@@ -31,4 +31,4 @@ public inline fun Node.clear() = this.newClear()
|
||||
replaceWith = ReplaceWith("this.appendText(text)", "kotlinx.dom.appendText")
|
||||
)
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.6")
|
||||
inline fun Element.appendText(text: String): Element = this.newAppendText(text)
|
||||
public inline fun Element.appendText(text: String): Element = this.newAppendText(text)
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.w3c.dom.*
|
||||
|
||||
/** Returns true if the element has the given CSS class style in its 'class' attribute */
|
||||
@SinceKotlin("1.4")
|
||||
fun Element.hasClass(cssClass: String): Boolean = className.matches("""(^|.*\s+)$cssClass($|\s+.*)""".toRegex())
|
||||
public fun Element.hasClass(cssClass: String): Boolean = className.matches("""(^|.*\s+)$cssClass($|\s+.*)""".toRegex())
|
||||
|
||||
/**
|
||||
* Adds CSS class to element. Has no effect if all specified classes are already in class attribute of the element
|
||||
@@ -17,7 +17,7 @@ fun Element.hasClass(cssClass: String): Boolean = className.matches("""(^|.*\s+)
|
||||
* @return true if at least one class has been added
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
fun Element.addClass(vararg cssClasses: String): Boolean {
|
||||
public fun Element.addClass(vararg cssClasses: String): Boolean {
|
||||
val missingClasses = cssClasses.filterNot { hasClass(it) }
|
||||
if (missingClasses.isNotEmpty()) {
|
||||
val presentClasses = className.trim()
|
||||
@@ -40,7 +40,7 @@ fun Element.addClass(vararg cssClasses: String): Boolean {
|
||||
* @return true if at least one class has been removed
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
fun Element.removeClass(vararg cssClasses: String): Boolean {
|
||||
public fun Element.removeClass(vararg cssClasses: String): Boolean {
|
||||
if (cssClasses.any { hasClass(it) }) {
|
||||
val toBeRemoved = cssClasses.toSet()
|
||||
className = className.trim().split("\\s+".toRegex()).filter { it !in toBeRemoved }.joinToString(" ")
|
||||
|
||||
@@ -21,7 +21,7 @@ public fun Node.clear() {
|
||||
* @return this element
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
fun Element.appendText(text: String): Element {
|
||||
public fun Element.appendText(text: String): Element {
|
||||
appendChild(ownerDocument!!.createTextNode(text))
|
||||
return this
|
||||
}
|
||||
|
||||
@@ -6,17 +6,17 @@
|
||||
package org.w3c.dom
|
||||
|
||||
@Deprecated("Use UnionMessagePortOrWindowProxy instead.", ReplaceWith("UnionMessagePortOrWindowProxy"))
|
||||
typealias UnionMessagePortOrWindow = UnionMessagePortOrWindowProxy
|
||||
public typealias UnionMessagePortOrWindow = UnionMessagePortOrWindowProxy
|
||||
|
||||
@Deprecated("Use `as` instead.", ReplaceWith("`as`"))
|
||||
var HTMLLinkElement.as_
|
||||
public var HTMLLinkElement.as_: org.w3c.fetch.RequestDestination
|
||||
get() = `as`
|
||||
set(value) {
|
||||
`as` = value
|
||||
}
|
||||
|
||||
@Deprecated("Use `is` instead.", ReplaceWith("`is`"))
|
||||
var ElementCreationOptions.is_
|
||||
public var ElementCreationOptions.is_: String?
|
||||
get() = `is`
|
||||
set(value) {
|
||||
`is` = value
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.w3c.dom.*
|
||||
|
||||
/** Returns true if the element has the given CSS class style in its 'class' attribute */
|
||||
@SinceKotlin("1.4")
|
||||
fun Element.hasClass(cssClass: String): Boolean = className.matches("""(^|.*\s+)$cssClass($|\s+.*)""".toRegex())
|
||||
public fun Element.hasClass(cssClass: String): Boolean = className.matches("""(^|.*\s+)$cssClass($|\s+.*)""".toRegex())
|
||||
|
||||
/**
|
||||
* Adds CSS class to element. Has no effect if all specified classes are already in class attribute of the element
|
||||
@@ -17,7 +17,7 @@ fun Element.hasClass(cssClass: String): Boolean = className.matches("""(^|.*\s+)
|
||||
* @return true if at least one class has been added
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
fun Element.addClass(vararg cssClasses: String): Boolean {
|
||||
public fun Element.addClass(vararg cssClasses: String): Boolean {
|
||||
val missingClasses = cssClasses.filterNot { hasClass(it) }
|
||||
if (missingClasses.isNotEmpty()) {
|
||||
val presentClasses = className.trim()
|
||||
@@ -40,7 +40,7 @@ fun Element.addClass(vararg cssClasses: String): Boolean {
|
||||
* @return true if at least one class has been removed
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
fun Element.removeClass(vararg cssClasses: String): Boolean {
|
||||
public fun Element.removeClass(vararg cssClasses: String): Boolean {
|
||||
if (cssClasses.any { hasClass(it) }) {
|
||||
val toBeRemoved = cssClasses.toSet()
|
||||
className = className.trim().split("\\s+".toRegex()).filter { it !in toBeRemoved }.joinToString(" ")
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
package org.w3c.dom
|
||||
|
||||
public external interface ItemArrayLike<out T : JsAny?> : JsAny {
|
||||
val length: Int
|
||||
fun item(index: Int): T?
|
||||
public val length: Int
|
||||
public fun item(index: Int): T?
|
||||
}
|
||||
|
||||
public fun <T : JsAny?> ItemArrayLike<T>.asList(): List<T> = object : AbstractList<T>() {
|
||||
|
||||
@@ -21,7 +21,7 @@ public fun Node.clear() {
|
||||
* @return this element
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
fun Element.appendText(text: String): Element {
|
||||
public fun Element.appendText(text: String): Element {
|
||||
appendChild(ownerDocument!!.createTextNode(text))
|
||||
return this
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user