From 365f8d025685abb90b8c3bc6838f6d2c15438b28 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Fri, 3 Feb 2017 18:02:18 +0300 Subject: [PATCH] Drop pre-1.0 deprecated dom helpers. --- js/js.libraries/src/deprecated/domCode.kt | 20 ---------- js/js.libraries/src/dom/Dom.kt | 47 ----------------------- js/js.libraries/src/dom/Mutations.kt | 12 ------ 3 files changed, 79 deletions(-) delete mode 100644 js/js.libraries/src/deprecated/domCode.kt diff --git a/js/js.libraries/src/deprecated/domCode.kt b/js/js.libraries/src/deprecated/domCode.kt deleted file mode 100644 index 228130e136c..00000000000 --- a/js/js.libraries/src/deprecated/domCode.kt +++ /dev/null @@ -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 diff --git a/js/js.libraries/src/dom/Dom.kt b/js/js.libraries/src/dom/Dom.kt index bef8f26898c..d5aa07638f5 100644 --- a/js/js.libraries/src/dom/Dom.kt +++ b/js/js.libraries/src/dom/Dom.kt @@ -33,20 +33,6 @@ fun Element?.childElements(): List = this?.childNodes?.filterElements() /** Returns the child elements of this element with the given name */ fun Element?.childElements(name: String): List = 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 - 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 - 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 = this?.elements(localName) ?: emptyList() - /** Returns all the descendant elements given the local element name */ fun Element.elements(localName: String = "*"): List { return this.getElementsByTagName(localName).asElementList() @@ -58,10 +44,6 @@ fun Document?.elements(localName: String = "*"): List { 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 = 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 { return this.getElementsByTagNameNS(namespaceUri, localName).asElementList() @@ -72,15 +54,8 @@ fun Document?.elements(namespaceUri: String, localName: String): List { 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 = this?.asList() ?: emptyList() - fun NodeList.asList(): List = NodeListAsList(this) -@Deprecated("Use asElementList() instead", ReplaceWith("this?.asElementList() ?: emptyList()"), level = DeprecationLevel.ERROR) -fun NodeList?.toElementList(): List = 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() diff --git a/js/js.libraries/src/dom/Mutations.kt b/js/js.libraries/src/dom/Mutations.kt index 4240d8e1722..d31d475cabf 100644 --- a/js/js.libraries/src/dom/Mutations.kt +++ b/js/js.libraries/src/dom/Mutations.kt @@ -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