Skip to content

Commit

Permalink
Add @SinceKotlin to kotlinx.browser and kotlinx.dom packages
Browse files Browse the repository at this point in the history
Add @DeprecatedSinceKotlin to kotlin.browser and kotlin.dom packages

(cherry picked from commit d86c142)
  • Loading branch information
trilis committed Aug 11, 2020
1 parent 74c8d74 commit d25b099
Show file tree
Hide file tree
Showing 16 changed files with 65 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libraries/stdlib/api/js-v1/kotlin.browser.kt
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
@kotlin.Deprecated(message = "This API is moved to another package, use 'kotlinx.browser.document' instead.", replaceWith = kotlin.ReplaceWith(expression = "document", imports = {"kotlinx.browser.document"}))
@kotlin.internal.LowPriorityInOverloadResolution
@kotlin.DeprecatedSinceKotlin(warningSince = "1.4")
public external val document: org.w3c.dom.Document { get; }

@kotlin.Deprecated(message = "This API is moved to another package, use 'kotlinx.browser.localStorage' instead.", replaceWith = kotlin.ReplaceWith(expression = "localStorage", imports = {"kotlinx.browser.localStorage"}))
@kotlin.internal.LowPriorityInOverloadResolution
@kotlin.DeprecatedSinceKotlin(warningSince = "1.4")
public external val localStorage: org.w3c.dom.Storage { get; }

@kotlin.Deprecated(message = "This API is moved to another package, use 'kotlinx.browser.sessionStorage' instead.", replaceWith = kotlin.ReplaceWith(expression = "sessionStorage", imports = {"kotlinx.browser.sessionStorage"}))
@kotlin.internal.LowPriorityInOverloadResolution
@kotlin.DeprecatedSinceKotlin(warningSince = "1.4")
public external val sessionStorage: org.w3c.dom.Storage { get; }

@kotlin.Deprecated(message = "This API is moved to another package, use 'kotlinx.browser.window' instead.", replaceWith = kotlin.ReplaceWith(expression = "window", imports = {"kotlinx.browser.window"}))
@kotlin.internal.LowPriorityInOverloadResolution
@kotlin.DeprecatedSinceKotlin(warningSince = "1.4")
public external val window: org.w3c.dom.Window { get; }
9 changes: 9 additions & 0 deletions libraries/stdlib/api/js-v1/kotlin.dom.kt
Original file line number Diff line number Diff line change
@@ -1,35 +1,44 @@
@kotlin.internal.LowPriorityInOverloadResolution
@kotlin.Deprecated(message = "This API is moved to another package, use 'kotlinx.dom.isElement' instead.", replaceWith = kotlin.ReplaceWith(expression = "this.isElement", imports = {"kotlinx.dom.isElement"}))
@kotlin.DeprecatedSinceKotlin(warningSince = "1.4")
public val org.w3c.dom.Node.isElement: kotlin.Boolean { get; }

@kotlin.internal.LowPriorityInOverloadResolution
@kotlin.Deprecated(message = "This API is moved to another package, use 'kotlinx.dom.isText' instead.", replaceWith = kotlin.ReplaceWith(expression = "this.isText", imports = {"kotlinx.dom.isText"}))
@kotlin.DeprecatedSinceKotlin(warningSince = "1.4")
public val org.w3c.dom.Node.isText: kotlin.Boolean { get; }

@kotlin.internal.LowPriorityInOverloadResolution
@kotlin.Deprecated(message = "This API is moved to another package, use 'kotlinx.dom.addClass' instead.", replaceWith = kotlin.ReplaceWith(expression = "this.addClass(cssClasses)", imports = {"kotlinx.dom.addClass"}))
@kotlin.DeprecatedSinceKotlin(warningSince = "1.4")
public inline fun org.w3c.dom.Element.addClass(vararg cssClasses: kotlin.String): kotlin.Boolean

@kotlin.internal.LowPriorityInOverloadResolution
@kotlin.Deprecated(message = "This API is moved to another package, use 'kotlinx.dom.appendElement' instead.", replaceWith = kotlin.ReplaceWith(expression = "this.appendElement(name, init)", imports = {"kotlinx.dom.appendElement"}))
@kotlin.DeprecatedSinceKotlin(warningSince = "1.4")
public inline fun org.w3c.dom.Element.appendElement(name: kotlin.String, noinline init: org.w3c.dom.Element.() -> kotlin.Unit): org.w3c.dom.Element

@kotlin.internal.LowPriorityInOverloadResolution
@kotlin.Deprecated(message = "This API is moved to another package, use 'kotlinx.dom.appendText' instead.", replaceWith = kotlin.ReplaceWith(expression = "this.appendText(text)", imports = {"kotlinx.dom.appendText"}))
@kotlin.DeprecatedSinceKotlin(warningSince = "1.4")
public inline fun org.w3c.dom.Element.appendText(text: kotlin.String): org.w3c.dom.Element

@kotlin.internal.LowPriorityInOverloadResolution
@kotlin.Deprecated(message = "This API is moved to another package, use 'kotlinx.dom.clear' instead.", replaceWith = kotlin.ReplaceWith(expression = "this.clear()", imports = {"kotlinx.dom.clear"}))
@kotlin.DeprecatedSinceKotlin(warningSince = "1.4")
public inline fun org.w3c.dom.Node.clear(): kotlin.Unit

@kotlin.internal.LowPriorityInOverloadResolution
@kotlin.Deprecated(message = "This API is moved to another package, use 'kotlinx.dom.createElement' instead.", replaceWith = kotlin.ReplaceWith(expression = "this.createElement(name, init)", imports = {"kotlinx.dom.createElement"}))
@kotlin.DeprecatedSinceKotlin(warningSince = "1.4")
public inline fun org.w3c.dom.Document.createElement(name: kotlin.String, noinline init: org.w3c.dom.Element.() -> kotlin.Unit): org.w3c.dom.Element

@kotlin.internal.LowPriorityInOverloadResolution
@kotlin.Deprecated(message = "This API is moved to another package, use 'kotlinx.dom.hasClass' instead.", replaceWith = kotlin.ReplaceWith(expression = "this.hasClass(cssClass)", imports = {"kotlinx.dom.hasClass"}))
@kotlin.DeprecatedSinceKotlin(warningSince = "1.4")
public inline fun org.w3c.dom.Element.hasClass(cssClass: kotlin.String): kotlin.Boolean

@kotlin.internal.LowPriorityInOverloadResolution
@kotlin.Deprecated(message = "This API is moved to another package, use 'kotlinx.dom.removeClass' instead.", replaceWith = kotlin.ReplaceWith(expression = "this.removeClass(cssClasses)", imports = {"kotlinx.dom.removeClass"}))
@kotlin.DeprecatedSinceKotlin(warningSince = "1.4")
public inline fun org.w3c.dom.Element.removeClass(vararg cssClasses: kotlin.String): kotlin.Boolean
4 changes: 4 additions & 0 deletions libraries/stdlib/api/js-v1/kotlinx.browser.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
/**/ @kotlin.SinceKotlin(version = "1.4")
/**/ public external val document: org.w3c.dom.Document { get; }
/**/
/**/ @kotlin.SinceKotlin(version = "1.4")
/**/ public external val localStorage: org.w3c.dom.Storage { get; }
/**/
/**/ @kotlin.SinceKotlin(version = "1.4")
/**/ public external val sessionStorage: org.w3c.dom.Storage { get; }
/**/
/**/ @kotlin.SinceKotlin(version = "1.4")
/**/ public external val window: org.w3c.dom.Window { get; }
9 changes: 9 additions & 0 deletions libraries/stdlib/api/js-v1/kotlinx.dom.kt
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
/**/ @kotlin.SinceKotlin(version = "1.4")
/**/ public val org.w3c.dom.Node.isElement: kotlin.Boolean { get; }
/**/
/**/ @kotlin.SinceKotlin(version = "1.4")
/**/ public val org.w3c.dom.Node.isText: kotlin.Boolean { get; }
/**/
/**/ @kotlin.SinceKotlin(version = "1.4")
/**/ public fun org.w3c.dom.Element.addClass(vararg cssClasses: kotlin.String): kotlin.Boolean
/**/
/**/ @kotlin.SinceKotlin(version = "1.4")
/**/ public fun org.w3c.dom.Element.appendElement(name: kotlin.String, init: org.w3c.dom.Element.() -> kotlin.Unit): org.w3c.dom.Element
/**/
/**/ @kotlin.SinceKotlin(version = "1.4")
/**/ public fun org.w3c.dom.Element.appendText(text: kotlin.String): org.w3c.dom.Element
/**/
/**/ @kotlin.SinceKotlin(version = "1.4")
/**/ public fun org.w3c.dom.Node.clear(): kotlin.Unit
/**/
/**/ @kotlin.SinceKotlin(version = "1.4")
/**/ public fun org.w3c.dom.Document.createElement(name: kotlin.String, init: org.w3c.dom.Element.() -> kotlin.Unit): org.w3c.dom.Element
/**/
/**/ @kotlin.SinceKotlin(version = "1.4")
/**/ public fun org.w3c.dom.Element.hasClass(cssClass: kotlin.String): kotlin.Boolean
/**/
/**/ @kotlin.SinceKotlin(version = "1.4")
/**/ public fun org.w3c.dom.Element.removeClass(vararg cssClasses: kotlin.String): kotlin.Boolean
4 changes: 4 additions & 0 deletions libraries/stdlib/api/js/kotlin.browser.kt
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
@kotlin.Deprecated(message = "This API is moved to another package, use 'kotlinx.browser.document' instead.", replaceWith = kotlin.ReplaceWith(expression = "document", imports = {"kotlinx.browser.document"}))
@kotlin.internal.LowPriorityInOverloadResolution
@kotlin.DeprecatedSinceKotlin(warningSince = "1.4")
public external val document: org.w3c.dom.Document { get; }

@kotlin.Deprecated(message = "This API is moved to another package, use 'kotlinx.browser.localStorage' instead.", replaceWith = kotlin.ReplaceWith(expression = "localStorage", imports = {"kotlinx.browser.localStorage"}))
@kotlin.internal.LowPriorityInOverloadResolution
@kotlin.DeprecatedSinceKotlin(warningSince = "1.4")
public external val localStorage: org.w3c.dom.Storage { get; }

@kotlin.Deprecated(message = "This API is moved to another package, use 'kotlinx.browser.sessionStorage' instead.", replaceWith = kotlin.ReplaceWith(expression = "sessionStorage", imports = {"kotlinx.browser.sessionStorage"}))
@kotlin.internal.LowPriorityInOverloadResolution
@kotlin.DeprecatedSinceKotlin(warningSince = "1.4")
public external val sessionStorage: org.w3c.dom.Storage { get; }

@kotlin.Deprecated(message = "This API is moved to another package, use 'kotlinx.browser.window' instead.", replaceWith = kotlin.ReplaceWith(expression = "window", imports = {"kotlinx.browser.window"}))
@kotlin.internal.LowPriorityInOverloadResolution
@kotlin.DeprecatedSinceKotlin(warningSince = "1.4")
public external val window: org.w3c.dom.Window { get; }
9 changes: 9 additions & 0 deletions libraries/stdlib/api/js/kotlin.dom.kt
Original file line number Diff line number Diff line change
@@ -1,35 +1,44 @@
@kotlin.internal.LowPriorityInOverloadResolution
@kotlin.Deprecated(message = "This API is moved to another package, use 'kotlinx.dom.isElement' instead.", replaceWith = kotlin.ReplaceWith(expression = "this.isElement", imports = {"kotlinx.dom.isElement"}))
@kotlin.DeprecatedSinceKotlin(warningSince = "1.4")
public val org.w3c.dom.Node.isElement: kotlin.Boolean { get; }

@kotlin.internal.LowPriorityInOverloadResolution
@kotlin.Deprecated(message = "This API is moved to another package, use 'kotlinx.dom.isText' instead.", replaceWith = kotlin.ReplaceWith(expression = "this.isText", imports = {"kotlinx.dom.isText"}))
@kotlin.DeprecatedSinceKotlin(warningSince = "1.4")
public val org.w3c.dom.Node.isText: kotlin.Boolean { get; }

@kotlin.internal.LowPriorityInOverloadResolution
@kotlin.Deprecated(message = "This API is moved to another package, use 'kotlinx.dom.addClass' instead.", replaceWith = kotlin.ReplaceWith(expression = "this.addClass(cssClasses)", imports = {"kotlinx.dom.addClass"}))
@kotlin.DeprecatedSinceKotlin(warningSince = "1.4")
public inline fun org.w3c.dom.Element.addClass(vararg cssClasses: kotlin.String): kotlin.Boolean

@kotlin.internal.LowPriorityInOverloadResolution
@kotlin.Deprecated(message = "This API is moved to another package, use 'kotlinx.dom.appendElement' instead.", replaceWith = kotlin.ReplaceWith(expression = "this.appendElement(name, init)", imports = {"kotlinx.dom.appendElement"}))
@kotlin.DeprecatedSinceKotlin(warningSince = "1.4")
public inline fun org.w3c.dom.Element.appendElement(name: kotlin.String, noinline init: org.w3c.dom.Element.() -> kotlin.Unit): org.w3c.dom.Element

@kotlin.internal.LowPriorityInOverloadResolution
@kotlin.Deprecated(message = "This API is moved to another package, use 'kotlinx.dom.appendText' instead.", replaceWith = kotlin.ReplaceWith(expression = "this.appendText(text)", imports = {"kotlinx.dom.appendText"}))
@kotlin.DeprecatedSinceKotlin(warningSince = "1.4")
public inline fun org.w3c.dom.Element.appendText(text: kotlin.String): org.w3c.dom.Element

@kotlin.internal.LowPriorityInOverloadResolution
@kotlin.Deprecated(message = "This API is moved to another package, use 'kotlinx.dom.clear' instead.", replaceWith = kotlin.ReplaceWith(expression = "this.clear()", imports = {"kotlinx.dom.clear"}))
@kotlin.DeprecatedSinceKotlin(warningSince = "1.4")
public inline fun org.w3c.dom.Node.clear(): kotlin.Unit

@kotlin.internal.LowPriorityInOverloadResolution
@kotlin.Deprecated(message = "This API is moved to another package, use 'kotlinx.dom.createElement' instead.", replaceWith = kotlin.ReplaceWith(expression = "this.createElement(name, init)", imports = {"kotlinx.dom.createElement"}))
@kotlin.DeprecatedSinceKotlin(warningSince = "1.4")
public inline fun org.w3c.dom.Document.createElement(name: kotlin.String, noinline init: org.w3c.dom.Element.() -> kotlin.Unit): org.w3c.dom.Element

@kotlin.internal.LowPriorityInOverloadResolution
@kotlin.Deprecated(message = "This API is moved to another package, use 'kotlinx.dom.hasClass' instead.", replaceWith = kotlin.ReplaceWith(expression = "this.hasClass(cssClass)", imports = {"kotlinx.dom.hasClass"}))
@kotlin.DeprecatedSinceKotlin(warningSince = "1.4")
public inline fun org.w3c.dom.Element.hasClass(cssClass: kotlin.String): kotlin.Boolean

@kotlin.internal.LowPriorityInOverloadResolution
@kotlin.Deprecated(message = "This API is moved to another package, use 'kotlinx.dom.removeClass' instead.", replaceWith = kotlin.ReplaceWith(expression = "this.removeClass(cssClasses)", imports = {"kotlinx.dom.removeClass"}))
@kotlin.DeprecatedSinceKotlin(warningSince = "1.4")
public inline fun org.w3c.dom.Element.removeClass(vararg cssClasses: kotlin.String): kotlin.Boolean
4 changes: 4 additions & 0 deletions libraries/stdlib/js/src/kotlin/browser/declarations.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,30 @@ import kotlin.internal.LowPriorityInOverloadResolution
replaceWith = ReplaceWith("window", "kotlinx.browser.window")
)
@LowPriorityInOverloadResolution
@DeprecatedSinceKotlin(warningSince = "1.4")
public external val window: Window

@Deprecated(
message = "This API is moved to another package, use 'kotlinx.browser.document' instead.",
replaceWith = ReplaceWith("document", "kotlinx.browser.document")
)
@LowPriorityInOverloadResolution
@DeprecatedSinceKotlin(warningSince = "1.4")
public external val document: Document

@Deprecated(
message = "This API is moved to another package, use 'kotlinx.browser.localStorage' instead.",
replaceWith = ReplaceWith("localStorage", "kotlinx.browser.localStorage")
)
@LowPriorityInOverloadResolution
@DeprecatedSinceKotlin(warningSince = "1.4")
public external val localStorage: Storage

@Deprecated(
message = "This API is moved to another package, use 'kotlinx.browser.sessionStorage' instead.",
replaceWith = ReplaceWith("sessionStorage", "kotlinx.browser.sessionStorage")
)
@LowPriorityInOverloadResolution
@DeprecatedSinceKotlin(warningSince = "1.4")
public external val sessionStorage: Storage

2 changes: 2 additions & 0 deletions libraries/stdlib/js/src/kotlin/dom/Builders.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import kotlinx.dom.createElement as newCreateElement
message = "This API is moved to another package, use 'kotlinx.dom.createElement' instead.",
replaceWith = ReplaceWith("this.createElement(name, init)", "kotlinx.dom.createElement")
)
@DeprecatedSinceKotlin(warningSince = "1.4")
public inline fun Document.createElement(name: String, noinline init: Element.() -> Unit): Element = this.newCreateElement(name, init)

/**
Expand All @@ -33,5 +34,6 @@ public inline fun Document.createElement(name: String, noinline init: Element.()
message = "This API is moved to another package, use 'kotlinx.dom.appendElement' instead.",
replaceWith = ReplaceWith("this.appendElement(name, init)", "kotlinx.dom.appendElement")
)
@DeprecatedSinceKotlin(warningSince = "1.4")
public inline fun Element.appendElement(name: String, noinline init: Element.() -> Unit): Element = this.newAppendElement(name, init)

3 changes: 3 additions & 0 deletions libraries/stdlib/js/src/kotlin/dom/Classes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import kotlinx.dom.removeClass as newRemoveClass
message = "This API is moved to another package, use 'kotlinx.dom.hasClass' instead.",
replaceWith = ReplaceWith("this.hasClass(cssClass)", "kotlinx.dom.hasClass")
)
@DeprecatedSinceKotlin(warningSince = "1.4")
inline fun Element.hasClass(cssClass: String): Boolean = this.newHasClass(cssClass)

/**
Expand All @@ -29,6 +30,7 @@ inline fun Element.hasClass(cssClass: String): Boolean = this.newHasClass(cssCla
message = "This API is moved to another package, use 'kotlinx.dom.addClass' instead.",
replaceWith = ReplaceWith("this.addClass(cssClasses)", "kotlinx.dom.addClass")
)
@DeprecatedSinceKotlin(warningSince = "1.4")
inline fun Element.addClass(vararg cssClasses: String): Boolean = this.newAddClass(*cssClasses)

/**
Expand All @@ -41,4 +43,5 @@ inline fun Element.addClass(vararg cssClasses: String): Boolean = this.newAddCla
message = "This API is moved to another package, use 'kotlinx.dom.removeClass' instead.",
replaceWith = ReplaceWith("this.removeClass(cssClasses)", "kotlinx.dom.removeClass")
)
@DeprecatedSinceKotlin(warningSince = "1.4")
inline fun Element.removeClass(vararg cssClasses: String): Boolean = this.newRemoveClass(*cssClasses)
2 changes: 2 additions & 0 deletions libraries/stdlib/js/src/kotlin/dom/Dom.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import kotlinx.dom.isText as newIsText
message = "This API is moved to another package, use 'kotlinx.dom.isText' instead.",
replaceWith = ReplaceWith("this.isText", "kotlinx.dom.isText")
)
@DeprecatedSinceKotlin(warningSince = "1.4")
public val Node.isText: Boolean
inline get() = this.newIsText

Expand All @@ -30,5 +31,6 @@ public val Node.isText: Boolean
message = "This API is moved to another package, use 'kotlinx.dom.isElement' instead.",
replaceWith = ReplaceWith("this.isElement", "kotlinx.dom.isElement")
)
@DeprecatedSinceKotlin(warningSince = "1.4")
public val Node.isElement: Boolean
inline get() = this.newIsElement
2 changes: 2 additions & 0 deletions libraries/stdlib/js/src/kotlin/dom/Mutations.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import kotlinx.dom.clear as newClear
message = "This API is moved to another package, use 'kotlinx.dom.clear' instead.",
replaceWith = ReplaceWith("this.clear()", "kotlinx.dom.clear")
)
@DeprecatedSinceKotlin(warningSince = "1.4")
public inline fun Node.clear() = this.newClear()

/**
Expand All @@ -29,4 +30,5 @@ public inline fun Node.clear() = this.newClear()
message = "This API is moved to another package, use 'kotlinx.dom.appendText' instead.",
replaceWith = ReplaceWith("this.appendText(text)", "kotlinx.dom.appendText")
)
@DeprecatedSinceKotlin(warningSince = "1.4")
inline fun Element.appendText(text: String): Element = this.newAppendText(text)
4 changes: 4 additions & 0 deletions libraries/stdlib/js/src/kotlinx/browser/declarations.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ package kotlinx.browser

import org.w3c.dom.*

@SinceKotlin("1.4")
public external val window: Window

@SinceKotlin("1.4")
public external val document: Document

@SinceKotlin("1.4")
public external val localStorage: Storage

@SinceKotlin("1.4")
public external val sessionStorage: Storage

2 changes: 2 additions & 0 deletions libraries/stdlib/js/src/kotlinx/dom/Builders.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import kotlin.contracts.*
*
* The element is initialized with the specified [init] function.
*/
@SinceKotlin("1.4")
public fun Document.createElement(name: String, init: Element.() -> Unit): Element {
contract { callsInPlace(init, InvocationKind.EXACTLY_ONCE) }
return createElement(name).apply(init)
Expand All @@ -23,6 +24,7 @@ public fun Document.createElement(name: String, init: Element.() -> Unit): Eleme
*
* The element is initialized with the specified [init] function.
*/
@SinceKotlin("1.4")
public fun Element.appendElement(name: String, init: Element.() -> Unit): Element {
contract { callsInPlace(init, InvocationKind.EXACTLY_ONCE) }
return ownerDocument!!.createElement(name, init).also { appendChild(it) }
Expand Down
3 changes: 3 additions & 0 deletions libraries/stdlib/js/src/kotlinx/dom/Classes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ package kotlinx.dom
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())

/**
* Adds CSS class to element. Has no effect if all specified classes are already in class attribute of the element
*
* @return true if at least one class has been added
*/
@SinceKotlin("1.4")
fun Element.addClass(vararg cssClasses: String): Boolean {
val missingClasses = cssClasses.filterNot { hasClass(it) }
if (missingClasses.isNotEmpty()) {
Expand All @@ -37,6 +39,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 {
if (cssClasses.any { hasClass(it) }) {
val toBeRemoved = cssClasses.toSet()
Expand Down
2 changes: 2 additions & 0 deletions libraries/stdlib/js/src/kotlinx/dom/Dom.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import org.w3c.dom.*
/**
* Gets a value indicating whether this node is a TEXT_NODE or a CDATA_SECTION_NODE.
*/
@SinceKotlin("1.4")
public val Node.isText: Boolean
get() = nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE

/**
* Gets a value indicating whether this node is an [Element].
*/
@SinceKotlin("1.4")
public val Node.isElement: Boolean
get() = nodeType == Node.ELEMENT_NODE
2 changes: 2 additions & 0 deletions libraries/stdlib/js/src/kotlinx/dom/Mutations.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package kotlinx.dom
import org.w3c.dom.*

/** Removes all the children from this node. */
@SinceKotlin("1.4")
public fun Node.clear() {
while (hasChildNodes()) {
removeChild(firstChild!!)
Expand All @@ -19,6 +20,7 @@ public fun Node.clear() {
*
* @return this element
*/
@SinceKotlin("1.4")
fun Element.appendText(text: String): Element {
appendChild(ownerDocument!!.createTextNode(text))
return this
Expand Down

0 comments on commit d25b099

Please sign in to comment.