mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:04:59 +00:00
LibWeb: Use correct offset value when replacing character data
Previously, the range's end offset was being set using it's previous value.
This commit is contained in:
parent
40246adfb9
commit
0577a664dd
3 changed files with 17 additions and 1 deletions
|
@ -0,0 +1 @@
|
|||
foo
|
|
@ -0,0 +1,15 @@
|
|||
<script src="../include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
const text = new Text("foobar");
|
||||
|
||||
const range = document.createRange();
|
||||
range.setEnd(text, 5);
|
||||
|
||||
text.deleteData(5, 1);
|
||||
text.deleteData(4, 1);
|
||||
text.deleteData(3, 1);
|
||||
|
||||
println(text.data);
|
||||
})
|
||||
</script>
|
|
@ -98,7 +98,7 @@ WebIDL::ExceptionOr<void> CharacterData::replace_data(size_t offset, size_t coun
|
|||
// 9. For each live range whose end node is node and end offset is greater than offset but less than or equal to offset plus count, set its end offset to offset.
|
||||
for (auto& range : Range::live_ranges()) {
|
||||
if (range->end_container() == this && range->end_offset() > offset && range->end_offset() <= (offset + count))
|
||||
TRY(range->set_end(*range->end_container(), range->end_offset()));
|
||||
TRY(range->set_end(*range->end_container(), offset));
|
||||
}
|
||||
|
||||
// 10. For each live range whose start node is node and start offset is greater than offset plus count, increase its start offset by data’s length and decrease it by count.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue