mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 00:04:58 +00:00

Similar to another problem we had in CharacterData, we were assuming that the offsets were raw utf8 byte offsets into the data, instead of utf16 code units. Fix this by using the substring helpers in CharacterData to get the text data from the Range. There are more instances of this issue around the place that we will need to track down and add tests for, but this fixes one of them :^) For the test included in this commit, we were previously returning: llo💨😮 Instead of the expected: llo💨😮 Wo
14 lines
432 B
HTML
14 lines
432 B
HTML
<body><p id="p1"><b>Hello💨</b>😮 World</p>
|
|
<script src="../include.js"></script>
|
|
<script>
|
|
test(() => {
|
|
const p1 = document.getElementById("p1");
|
|
const hello = p1.firstChild.firstChild;
|
|
const world = p1.lastChild;
|
|
const range = document.createRange();
|
|
range.setStart(hello, 2);
|
|
range.setEnd(world, 5);
|
|
println('');
|
|
println(range.toString());
|
|
});
|
|
</script>
|