function testPositions(node) {
node.insertAdjacentHTML("beforeBegin", "\u003Cscript>ok(false, 'script should not have run');\u003C/script>");
is(node.previousSibling.localName, "i", "Should have had as previous sibling");
node.insertAdjacentHTML("Afterbegin", "\u003Cscript>ok(false, 'script should not have run');\u003C/script>");
is(node.firstChild.localName, "b", "Should have had as first child");
node.insertAdjacentHTML("BeforeEnd", "\u003Cscript>ok(false, 'script should not have run');\u003C/script>");
is(node.lastChild.localName, "u", "Should have had as last child");
node.insertAdjacentHTML("afterend", "\u003Cscript>ok(false, 'script should not have run');\u003C/script>");
is(node.nextSibling.localName, "a", "Should have had as next sibling");
}
var content = document.getElementById("content");
testPositions(content); // without next sibling
testPositions(content); // test again when there's next sibling
try {
content.insertAdjacentHTML("bar", "foo");
ok(false, "insertAdjacentHTML should have thrown");
} catch (e) {
is(e.name, "SyntaxError", "insertAdjacentHTML should throw SyntaxError");
is(e.code, 12, "insertAdjacentHTML should throw SYNTAX_ERR");
}
var parent = document.createElement("div"); var child = document.createElement("div");
try {
child.insertAdjacentHTML("Beforebegin", "foo");
ok(false, "insertAdjacentHTML should have thrown");
} catch (e) {
is(e.name, "NoModificationAllowedError", "insertAdjacentHTML should throw NoModificationAllowedError");
is(e.code, 7, "insertAdjacentHTML should throw NO_MODIFICATION_ALLOWED_ERR");
}
try {
child.insertAdjacentHTML("AfterEnd", "foo");
ok(false, "insertAdjacentHTML should have thrown");
} catch (e) {
is(e.name, "NoModificationAllowedError", "insertAdjacentHTML should throw NoModificationAllowedError");
is(e.code, 7, "insertAdjacentHTML should throw NO_MODIFICATION_ALLOWED_ERR");
}
);
is(document.getElementsByTagName("head").length, 1, "Should still have one head");
is(document.getElementsByTagName("body").length, 1, "Should still have one body");
</script>
</pre>
</body></html>
¤ Dauer der Verarbeitung: 0.28 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.