[w3c/editing] Firefox: event.getTargetRanges() in beforeinput not consistent with window.getSelection() (Issue #493)

michael created an issue (w3c/editing#493)

Assuming you have this markup:

```html
<div contenteditable="true">Hello world</div>
```

Now select the whole "Hello world" by triple clicking or pressing CTRL+A.

Now watch the onbeforeinput handler, when typing a character or hitting backspace.

```js
function onbeforeinput(event) {
  // I'd expect the two logs below to show the same element
  // On Chrome/Safari they do, but not in Firefox
  console.log(event.getTargetRanges()[0].startContainer); // returns the div
  console.log(window.getSelection().anchorNode); // returns the "Hello world" text node
}
```


Repro: https://michael.github.io/web-editing/repros/012.html

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/editing/issues/493
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/editing/issues/493@github.com>

Received on Monday, 17 November 2025 13:25:54 UTC