Drop pre-1.0 deprecated dom helpers.
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
package kotlin.dom
|
||||
|
||||
import org.w3c.dom.Document
|
||||
import org.w3c.dom.Node
|
||||
|
||||
@Deprecated("use declarations from org.w3c.dom instead: create document directly via constructor Document() or use document.implementation.createDocument", level = DeprecationLevel.ERROR)
|
||||
public fun createDocument(): Document = Document()
|
||||
|
||||
@Deprecated("use member property outerHTML of Element class instead", level = DeprecationLevel.ERROR)
|
||||
public inline val Node.outerHTML: String get() = asDynamic().outerHTML
|
||||
|
||||
/** Converts the node to an XML String */
|
||||
@Deprecated("use outerHTML directly", level = DeprecationLevel.ERROR)
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public fun Node.toXmlString(): String = this.outerHTML
|
||||
|
||||
/** Converts the node to an XML String */
|
||||
@Deprecated("use outerHTML directly", level = DeprecationLevel.ERROR)
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public fun Node.toXmlString(xmlDeclaration: Boolean): String = this.outerHTML
|
||||
@@ -33,20 +33,6 @@ fun Element?.childElements(): List<Element> = this?.childNodes?.filterElements()
|
||||
/** Returns the child elements of this element with the given name */
|
||||
fun Element?.childElements(name: String): List<Element> = this?.childNodes?.filterElements()?.filter { it.nodeName == name } ?: emptyList()
|
||||
|
||||
/** The descendant elements of this document */
|
||||
@Deprecated("Use elements() function instead", ReplaceWith("this.elements()"), level = DeprecationLevel.ERROR)
|
||||
val Document?.elements: List<Element>
|
||||
get() = this.elements()
|
||||
|
||||
/** The descendant elements of this elements */
|
||||
@Deprecated("Use elements() function instead", ReplaceWith("this?.elements() ?: emptyList()"), level = DeprecationLevel.ERROR)
|
||||
val Element?.elements: List<Element>
|
||||
get() = this?.elements() ?: emptyList()
|
||||
|
||||
@Deprecated("Use non-nullable receiver version elements()", ReplaceWith("this?.elements(localName) ?: emptyList()"), level = DeprecationLevel.ERROR)
|
||||
@JsName("deprecated_elements")
|
||||
fun Element?.elements(localName: String): List<Element> = this?.elements(localName) ?: emptyList()
|
||||
|
||||
/** Returns all the descendant elements given the local element name */
|
||||
fun Element.elements(localName: String = "*"): List<Element> {
|
||||
return this.getElementsByTagName(localName).asElementList()
|
||||
@@ -58,10 +44,6 @@ fun Document?.elements(localName: String = "*"): List<Element> {
|
||||
return this?.getElementsByTagName(localName)?.asElementList() ?: emptyList()
|
||||
}
|
||||
|
||||
@Deprecated("Use non-nullable elements function instead", ReplaceWith("this?.elements(namespaceUri, localName) ?: emptyList()"), level = DeprecationLevel.ERROR)
|
||||
@JsName("deprecated_elements_2")
|
||||
fun Element?.elements(namespaceUri: String, localName: String): List<Element> = this?.elements(namespaceUri, localName) ?: emptyList()
|
||||
|
||||
/** Returns all the descendant elements given the namespace URI and local element name */
|
||||
fun Element.elements(namespaceUri: String, localName: String): List<Element> {
|
||||
return this.getElementsByTagNameNS(namespaceUri, localName).asElementList()
|
||||
@@ -72,15 +54,8 @@ fun Document?.elements(namespaceUri: String, localName: String): List<Element> {
|
||||
return this?.getElementsByTagNameNS(namespaceUri, localName)?.asElementList() ?: emptyList()
|
||||
}
|
||||
|
||||
@Deprecated("Use non-null function instead with elvis", ReplaceWith("this?.asList() ?: emptyList()"), level = DeprecationLevel.ERROR)
|
||||
@JsName("deprecated_asList")
|
||||
fun NodeList?.asList(): List<Node> = this?.asList() ?: emptyList()
|
||||
|
||||
fun NodeList.asList(): List<Node> = NodeListAsList(this)
|
||||
|
||||
@Deprecated("Use asElementList() instead", ReplaceWith("this?.asElementList() ?: emptyList()"), level = DeprecationLevel.ERROR)
|
||||
fun NodeList?.toElementList(): List<Element> = this?.asElementList() ?: emptyList()
|
||||
|
||||
/**
|
||||
* Returns view with assumption that it contains only elements. Will crash in runtime if there are non-element nodes in
|
||||
* the list during access such items. So [filterElements] would be better solution.
|
||||
@@ -162,25 +137,3 @@ val Node.isText: Boolean
|
||||
*/
|
||||
val Node.isElement: Boolean
|
||||
get() = nodeType == Node.ELEMENT_NODE
|
||||
|
||||
/** Returns the attribute value or empty string if its not present */
|
||||
@Deprecated("Use getAttribute with elvis operator", ReplaceWith("this.getAttribute(name) ?: \"\""), level = DeprecationLevel.ERROR)
|
||||
fun Element.attribute(name: String): String {
|
||||
return this.getAttribute(name) ?: ""
|
||||
}
|
||||
|
||||
@Deprecated("Use asList().firstOrNull() instead", ReplaceWith("this?.asList()?.firstOrNull()"), level = DeprecationLevel.ERROR)
|
||||
val NodeList?.head: Node?
|
||||
get() = this?.asList()?.firstOrNull()
|
||||
|
||||
@Deprecated("Use asList().firstOrNull() instead", ReplaceWith("this?.asList()?.firstOrNull()"), level = DeprecationLevel.ERROR)
|
||||
val NodeList?.first: Node?
|
||||
get() = this?.asList()?.firstOrNull()
|
||||
|
||||
@Deprecated("Use asList().lastOrNull() instead", ReplaceWith("this?.asList()?.lastOrNull()"), level = DeprecationLevel.ERROR)
|
||||
val NodeList?.last: Node?
|
||||
get() = this?.asList()?.lastOrNull()
|
||||
|
||||
@Deprecated("Use asList().lastOrNull() instead instead", ReplaceWith("last"), level = DeprecationLevel.ERROR)
|
||||
val NodeList?.tail: Node?
|
||||
get() = this?.asList()?.lastOrNull()
|
||||
|
||||
@@ -32,18 +32,6 @@ fun Node.ownerDocument(doc: Document? = null): Document = when {
|
||||
else -> doc ?: ownerDocument ?: throw IllegalArgumentException("Neither node contains nor parameter doc provides an owner document for $this")
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a newly created text node to an element which either already has an owner Document or one must be provided as a parameter
|
||||
*/
|
||||
@Deprecated("Use appendText() instead", ReplaceWith("appendText(text, doc)"), level = DeprecationLevel.ERROR)
|
||||
fun Element.addText(text: String, doc: Document? = null): Element = appendText(text, doc)
|
||||
|
||||
/**
|
||||
* Adds a newly created text node to an element which either already has an owner Document or one must be provided as a parameter
|
||||
*/
|
||||
@Deprecated("Use appendText() instead", ReplaceWith("appendText(text)"), level = DeprecationLevel.ERROR)
|
||||
fun Element.addText(text: String): Element = appendText(text)
|
||||
|
||||
|
||||
/**
|
||||
* Creates text node and append it to the element
|
||||
|
||||
Reference in New Issue
Block a user