ladybird/Tests/LibWeb/Text/input/text-insertData.html
Aliaksandr Kalenik 42b31820a6 LibWeb: Use UTF-16 code units length in CharacterData::replace_data()
Range API uses UTF-16 code units to represent offsets, so replace_data()
needs to use it instead of bytes count while calculating new offsets.

Fixes incorrectly thrown exception when non-latin string is passed into
replace_data().
2024-11-06 05:46:30 +00:00

13 lines
416 B
HTML

<!DOCTYPE html>
<script src="include.js"></script>
<div id="text">==</div>
<script>
test(() => {
const text = document.getElementById("text");
const range = document.createRange();
range.setStart(text.firstChild, 0);
range.setEnd(text.firstChild, text.firstChild.length);
text.firstChild.insertData(1, "Привет");
println(range.toString());
});
</script>