ladybird/Tests/LibWeb/Ref/expected/range-not-assiciated-with-selection-should-not-affect-it-ref.html
Aliaksandr Kalenik 5874b7a76f LibWeb: Skip update_associated_selection() when there's no selection
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.
2025-07-03 22:16:39 +02:00

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>