[w3c/selection-api] Skip posting a task for `selectionchange` event in some cases (Issue #170)

Hello!

We may consider to skip posting a task for the `selectionchange` event in some specific cases like:

- Skip posting a task for `selectionchange` event if there are no registered listeners;
- Skip posting a task for `selectionchange` event if the UA already has an queued task for an equivalent `selectionchange` event;

Here is a simple case when we don't have any registered listener:
```
<!DOCTYPE html>
<html>
<form>
    <div>
        <input
        class="toggle-all"
        type="text"
        id="inputtext"
        name="subscribe"
        value="hello world"/>
    </div>
  </form>

  <script>
  var tx = document.getElementById("inputtext");
  tx.focus();
  for (var i = 0; i < 100; i++) {

    console.time("set value");
    tx.value = 'something to do ' + i;
    console.timeEnd("set value");
  }
  </script>
  </html>
```

Based the below chrome trace, it is noticed that although we don't register any listener, it still posts an async task when we are just changing the text value.
![selectionchange-for-w3c](https://github.com/w3c/selection-api/assets/76035035/6b038f84-2432-4452-a68e-4c3ca4fc5bf1)


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

Message ID: <w3c/selection-api/issues/170@github.com>

Received on Thursday, 1 February 2024 05:08:48 UTC