|
// retoor <retoor@molodetz.nl>
|
|
|
|
import "html" for Document
|
|
|
|
var doc = Document.parse("<div><p>Hello</p></div>")
|
|
System.print(doc.documentElement != null) // expect: true
|
|
|
|
var doc2 = Document.parse("<html><head><title>Test</title></head><body><div id=\"main\">Content</div></body></html>")
|
|
System.print(doc2.head != null) // expect: true
|
|
System.print(doc2.body != null) // expect: true
|
|
System.print(doc2.title) // expect: Test
|
|
|
|
var doc3 = Document.parse("<div class=\"foo bar\" data-id=\"123\">Text</div>")
|
|
var div = doc3.querySelector("div")
|
|
System.print(div.className) // expect: foo bar
|
|
System.print(div.getAttribute("data-id")) // expect: 123
|
|
|
|
var doc4 = Document.parse("<img src=\"test.png\" />")
|
|
var img = doc4.querySelector("img")
|
|
System.print(img.tagName) // expect: IMG
|
|
System.print(img.getAttribute("src")) // expect: test.png
|