LibWeb: Allow splitting surrogate pairs in CharacterData.substringData()

This commit is contained in:
Shannon Booth 2024-10-20 13:50:39 +13:00 committed by Tim Ledbetter
commit b999f925dc
Notes: github-actions[bot] 2024-10-20 10:19:54 +00:00
3 changed files with 25 additions and 2 deletions

View file

@ -0,0 +1,18 @@
<script src="../include.js"></script>
<script>
test(() => {
const str = '\uD83D\uDC36'; // 🐶
let t = document.createTextNode(str);
println("Before substringData:");
for (let i = 0; i < t.length; ++i) {
println("[" + i + "]: " + t.data.charCodeAt(i));
}
// Break the surrogate pair
const invalidSubstring = t.substringData(0, 1);
println("After substringData(0, 1):");
for (let i = 0; i < invalidSubstring.length; ++i) {
println("[" + i + "]: " + invalidSubstring.charCodeAt(i));
}
});
</script>