Files
kotlin-fork/js/js.translator/testFiles/stdlib/cases/browserDocumentAccess.kt
T
develar 764b5c5a90 JS backend: use generated code(org.w3c.*) for browser API.
#KT-2983 in progress

(cherry picked from commit 8b839a9)
2013-09-20 17:21:13 +04:00

13 lines
560 B
Kotlin

package test.browser
import js.dom.html.document
import org.w3c.dom.Node
fun foo(): String {
val element = document.getElementById("foo")!!
val textNode = document.createTextNode("Some Dynamically Created Content!!!")
element.appendChild(textNode)
if (textNode.nodeType != Node.TEXT_NODE) return "The type of the node is ${textNode.nodeType}, ${Node.TEXT_NODE} was expected"
if (element.nodeType != Node.ELEMENT_NODE) return "The type of the node is ${element.nodeType}, ${Node.ELEMENT_NODE} was expected"
return element.textContent
}