serenity icon indicating copy to clipboard operation
serenity copied to clipboard

LibWeb: Use correct offset value when replacing character data

Open tcl3 opened this issue 1 year ago • 2 comments

Previously, the range's end offset was being set using it's previous value.

This fixes an issue where editing contenteditable elements would crash intermittently when removing characters.

Tested by editing the following test page:

<!DOCTYPE html>
<div contenteditable>Deleting characters from here causes intermittent crashes</div>

tcl3 avatar Feb 06 '24 19:02 tcl3

Is it possible to add a Text test for it?

shannonbooth avatar Feb 06 '24 20:02 shannonbooth

Is it possible to add a Text test for it?

I've added a test case that exposes the bug. The test throws a DOMException on master rather than crashing WebContent like editing a contenteditable does. I believe the root cause is the same though.

tcl3 avatar Feb 08 '24 17:02 tcl3