Modified StdLibTest to check for node types of the created elements

This commit is contained in:
pTalanov
2012-06-15 15:08:21 +04:00
parent c1a2eaf47a
commit bdd83d86f6
2 changed files with 18 additions and 2 deletions
@@ -1,11 +1,15 @@
package test.browser
import kotlin.browser.document
import org.w3c.dom.Node
fun foo(): String {
val element = document.getElementById("foo")
if (element != null) {
element.appendChild(document.createTextNode("Some Dynamically Created Content!!!"))
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
}