|
// retoor <retoor@molodetz.nl>
|
|
|
|
import "html" for Document
|
|
|
|
var doc = Document.parse("<div id='container'></div>")
|
|
|
|
var container = doc.getElementById("container")
|
|
System.print(container.children.count) // expect: 0
|
|
|
|
var p = doc.createElement("p")
|
|
p.textContent = "First"
|
|
container.appendChild(p)
|
|
System.print(container.children.count) // expect: 1
|
|
System.print(container.firstChild.textContent) // expect: First
|
|
|
|
var span = doc.createElement("span")
|
|
span.textContent = "Second"
|
|
container.appendChild(span)
|
|
System.print(container.children.count) // expect: 2
|
|
System.print(container.lastChild.textContent) // expect: Second
|
|
|
|
var text = doc.createTextNode("Text node")
|
|
container.appendChild(text)
|
|
System.print(container.textContent.contains("Text node")) // expect: true
|
|
|