|
// retoor <retoor@molodetz.nl>
|
|
|
|
import "html" for Document
|
|
|
|
var doc = Document.parse("<div class='a b c'>Content</div>")
|
|
|
|
var div = doc.querySelector("div")
|
|
var list = div.classList
|
|
System.print(list.count) // expect: 3
|
|
System.print(list[0]) // expect: a
|
|
System.print(list[1]) // expect: b
|
|
System.print(list[2]) // expect: c
|
|
|
|
var noClass = Document.parse("<span>No Class</span>")
|
|
var span = noClass.querySelector("span")
|
|
var emptyList = span.classList
|
|
System.print(emptyList.count) // expect: 0
|
|
|
|
var single = Document.parse("<p class='only'>Text</p>")
|
|
var p = single.querySelector("p")
|
|
System.print(p.classList.count) // expect: 1
|
|
System.print(p.classList[0]) // expect: only
|
|
|