LibWeb: Implement document.createCDATASection()

This commit is contained in:
Tim Ledbetter 2024-02-18 14:27:25 +00:00 committed by Andreas Kling
commit 02c2b1e67e
Notes: sideshowbarker 2024-07-17 02:42:21 +09:00
6 changed files with 45 additions and 1 deletions

View file

@ -0,0 +1,21 @@
<script src="../include.js"></script>
<script>
test(() => {
const xmlDocument = new DOMParser().parseFromString("<xml></xml>", "application/xml");
const validCdata = xmlDocument.createCDATASection("Some <CDATA> data & then some");
xmlDocument.querySelector("xml").appendChild(validCdata);
println(new XMLSerializer().serializeToString(xmlDocument));
try {
document.createCDATASection("This isn't valid for HTML documents")
} catch (e) {
println(`Exception: ${e.name}`);
}
try {
const cdataWithAnEndDelimiter = xmlDocument.createCDATASection("This: ']]>' is a CDATA end delimiter");
} catch (e) {
println(`Exception: ${e.name}`);
}
});
</script>