Base: Add two HTML test pages for DOM cloneNode() functionality

This commit is contained in:
Andreas Kling 2022-12-13 13:26:10 +01:00
parent b005e816a3
commit 7a51e846b2
Notes: sideshowbarker 2024-07-17 03:14:48 +09:00
2 changed files with 69 additions and 0 deletions

View file

@ -0,0 +1,38 @@
<html>
<body>
<pre id="out"></pre>
<script>
function log(s) {
document.getElementById("out").innerHTML += s + "\n"
}
window.onload = function() {
let e = document.createElement("div")
e.setAttribute("foo", "bar")
let attr = e.getAttributeNode("foo")
let clone = attr.cloneNode()
function dumpAttr(name, attr) {
log(name + ": " + attr)
log(name + ".ownerElement: " + attr.ownerElement)
log(name + ".namespaceURI: " + attr.namespaceURI)
log(name + ".localName: " + attr.localName)
log(name + ".name: " + attr.name)
log(name + ".value: " + attr.value)
log(name + ".specified: " + attr.specified)
log("")
}
dumpAttr("attr", attr)
dumpAttr("clone", clone)
log("attr === clone -> " + (attr === clone))
log("attr.isEqualNode(clone) -> " + attr.isEqualNode(clone))
e.setAttribute("baz", "bux")
let other = e.getAttributeNode("baz")
log("attr.isEqualNode(other) -> " + attr.isEqualNode(other))
}
</script>
</body>
</html>

View file

@ -0,0 +1,31 @@
<html>
<body>
<pre id="out"></pre>
<script>
function log(s) {
document.getElementById("out").innerHTML += s + "\n"
}
window.onload = function() {
let pi = document.createProcessingInstruction("someTarget", "someData")
let clone = pi.cloneNode()
function dumpProcessingInstruction(name, pi) {
log(name + ": " + pi)
log(name + ".target: " + pi.target)
log(name + ".data: " + pi.data)
log("")
}
dumpProcessingInstruction("pi", pi)
dumpProcessingInstruction("clone", clone)
log("pi === clone -> " + (pi === clone))
log("pi.isEqualNode(clone) -> " + pi.isEqualNode(clone))
let other = document.createProcessingInstruction("baz", "bux")
log("pi.isEqualNode(other) -> " + pi.isEqualNode(other))
}
</script>
</body>
</html>