mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 03:39:17 +00:00
This change fixes at least two issues: - `update_associated_selection()` is responsible for selectionchange dispatch, and we were incorrectly dispatching this event on ranges that were not associated with a selection. - `Range::get_client_rects()` was using `update_associated_selection()` to refresh the selection state in the paintable tree for the current range, but since a range might not be associated with a selection, this could make the painted selection reflect the state of an arbitrary range instead of the actual selection range. Fixes a bug on Discord where any text typed into the message input would get selected.
17 lines
518 B
HTML
17 lines
518 B
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<body>
|
|
<p id="text">This is a simple sentence used to test range and selection rectangles.</p>
|
|
<script>
|
|
const textNode = document.getElementById("text").firstChild;
|
|
|
|
const sel = window.getSelection();
|
|
sel.removeAllRanges();
|
|
|
|
const selRange = document.createRange();
|
|
selRange.setStart(textNode, 5);
|
|
selRange.setEnd(textNode, 16);
|
|
sel.addRange(selRange);
|
|
</script>
|
|
</body>
|
|
</html>
|