|
// retoor <retoor@molodetz.nl>
|
|
|
|
import "html" for Document
|
|
|
|
var doc = Document.parse("<div id='container'><p id='para'>Text</p><span>Other</span></div>")
|
|
|
|
var container = doc.getElementById("container")
|
|
System.print(container.children.count) // expect: 2
|
|
|
|
var para = doc.getElementById("para")
|
|
para.remove()
|
|
|
|
System.print(container.children.count) // expect: 1
|
|
System.print(container.firstChild.tagName) // expect: SPAN
|
|
|
|
var doc2 = Document.parse("<ul><li>A</li><li>B</li><li>C</li></ul>")
|
|
var ul = doc2.querySelector("ul")
|
|
var items = doc2.querySelectorAll("li")
|
|
System.print(items.count) // expect: 3
|
|
|
|
items[1].remove()
|
|
System.print(ul.children.count) // expect: 2
|
|
|