During a code execution, the Selection API's boundary-points can change multiple times.
For example:
const sel = getSelection();
...
sel.removeAllRanges();
sel.addRange(range1);
...
sel.removeAllRanges();
sel.addRange(range2)
The spec does not specify how many times the selectionchange event should fire if we change the selection multiple times before the macrotask queue gets executed.
In Chromium and WebKit, the selectionchange fires multiple times, even though the Selecion will be the same by the time it gets executed.
In Gecko, it fires once.
During a code execution, the Selection API's boundary-points can change multiple times. For example:
The spec does not specify how many times the
selectionchange
event should fire if we change the selection multiple times before the macrotask queue gets executed.Demo to reproduce: https://codepen.io/IDontHaveAny/pen/OJemybj
In Chromium and WebKit, the
selectionchange
fires multiple times, even though theSelecion
will be the same by the time it gets executed. In Gecko, it fires once.