|
// retoor <retoor@molodetz.nl>
|
|
|
|
import "html" for Document
|
|
|
|
var doc = Document.parse("<div id='original' class='box'><p>Child</p><span>Another</span></div>")
|
|
|
|
var original = doc.getElementById("original")
|
|
|
|
var shallow = original.cloneNode(false)
|
|
System.print(shallow.tagName) // expect: DIV
|
|
System.print(shallow.id) // expect: original
|
|
System.print(shallow.className) // expect: box
|
|
System.print(shallow.children.count) // expect: 0
|
|
|
|
var deep = original.cloneNode(true)
|
|
System.print(deep.tagName) // expect: DIV
|
|
System.print(deep.id) // expect: original
|
|
System.print(deep.children.count) // expect: 2
|
|
System.print(deep.firstChild.tagName) // expect: P
|
|
System.print(deep.lastChild.tagName) // expect: SPAN
|
|
|
|
deep.id = "cloned"
|
|
System.print(original.id) // expect: original
|
|
System.print(deep.id) // expect: cloned
|
|
|