- From: Dan Clark via GitHub <sysbot+gh@w3.org>
- Date: Mon, 08 Aug 2022 23:39:11 +0000
- To: public-css-archive@w3.org
> That example doesn't work. One can't dispatch an event which is already being dispatched.
Hmm, that certainly poses a problem. Unless we'd be willing to tell devs to do `setTimeout(() => { e.ranges = ranges; highlight.dispatchEvent(e); }, 0)` in the Document's event handler, I guess we'd need to add another API to hand off the event to Highlights:
```
partial interface Highlight {
// Once the event has finished dispatching, dispatch it again against this Highlight
// with event.ranges set to ranges.
void handleEventAsync(Event event, sequence<AbstrangeRange> ranges);
}
```
This would be called in the `for` loop of the Document's event handler, instead of calling `dispatchEvent` directly. Setting `e.ranges` during the initial `for` loop no longer works since this is asynchronous, hence the extra `ranges` parameter.
Is there a better way to work around this problem? This is becoming sufficiently cumbersome that I'm thinking this approach's initial goal of simplicity is no longer being achieved.
--
GitHub Notification of comment by dandclark
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7513#issuecomment-1208729019 using your GitHub account
--
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Monday, 8 August 2022 23:39:13 UTC