|
// retoor <retoor@molodetz.nl>
|
|
|
|
import "html" for Document
|
|
|
|
var doc = Document.parse("<div><p>One</p><span>Two</span><a>Three</a></div>")
|
|
|
|
var div = doc.querySelector("div")
|
|
|
|
System.print(div.children.count) // expect: 3
|
|
System.print(div.children[0].tagName) // expect: P
|
|
System.print(div.children[1].tagName) // expect: SPAN
|
|
System.print(div.children[2].tagName) // expect: A
|
|
|
|
System.print(div.childNodes.count >= 3) // expect: true
|
|
|
|
System.print(div.firstChild != null) // expect: true
|
|
System.print(div.lastChild != null) // expect: true
|
|
|
|
System.print(div.firstElementChild.tagName) // expect: P
|
|
System.print(div.lastElementChild.tagName) // expect: A
|
|
|
|
var empty = doc.createElement("div")
|
|
System.print(empty.children.count) // expect: 0
|
|
System.print(empty.firstChild == null) // expect: true
|
|
System.print(empty.lastChild == null) // expect: true
|
|
System.print(empty.firstElementChild == null) // expect: true
|
|
System.print(empty.lastElementChild == null) // expect: true
|
|
|