LibWeb: Calculate length for all CharacterData type nodes correctly

We now ensure that `Node::is_character_data()` returns true for all
nodes of type character data.

Previously, calling `Node::length()` on `CDataSection` or
`ProcessingInstruction` nodes would return an incorrect value.
This commit is contained in:
Tim Ledbetter 2024-07-23 21:55:48 +01:00 committed by Sam Atkins
commit 3802d9ccc4
Notes: github-actions[bot] 2024-07-25 14:58:20 +00:00
3 changed files with 14 additions and 1 deletions

View file

@ -0,0 +1,11 @@
<script src="../include.js"></script>
<script>
test(() => {
const xmlDocument = new DOMParser().parseFromString(`<xml></xml>`, "application/xml");
const cdata = xmlDocument.createCDATASection("DATA");
const range = xmlDocument.createRange();
range.setStart(cdata, 0);
range.setEnd(cdata, 3);
println(`range start offset: ${range.startOffset}, end offset: ${range.endOffset}`);
});
</script>