Clarify dispatchEvent synchronous handler wording#43973
Clarify dispatchEvent synchronous handler wording#43973
Conversation
| Unlike "native" events, which are fired by the browser and dispatched | ||
| asynchronously via the [event loop](/en-US/docs/Web/JavaScript/Reference/Execution_model), | ||
| `dispatchEvent()` invokes event handlers _synchronously_. All applicable event | ||
| handlers are called and return before `dispatchEvent()` returns. |
There was a problem hiding this comment.
Thanks! That's better but I believe that the dispatch operation to add the events to the event loop is synchronous - and then the actual firing is async. We could say "dispatched to the event loop and fired asyncronously" but perhaps that is too many "fired" for one sentence.
Further, it precedes your change, but this compares native event firing and dispatchEvent handling in a kind of messy way. What do you think about this tidy up?
| Unlike "native" events, which are fired by the browser and dispatched | |
| asynchronously via the [event loop](/en-US/docs/Web/JavaScript/Reference/Execution_model), | |
| `dispatchEvent()` invokes event handlers _synchronously_. All applicable event | |
| handlers are called and return before `dispatchEvent()` returns. | |
| Unlike "native" events, which the browser fires by queuing a task on the [event loop](https://github.com/en-US/docs/Web/JavaScript/Reference/Execution_model), `dispatchEvent()` invokes all applicable event handlers _synchronously_ before returning. |
There was a problem hiding this comment.
@hamishwillee there's an ongoing long thread to fix this prose in #43521.
Suggest we close #43973 as duplicate?
There was a problem hiding this comment.
@dipikabh That predates this and is ongoing, so perhaps rude to shut it down.
|
Thanks for the feedback, @hamishwillee! You're right—referencing the 'queuing a task' mechanism is much more precise. I've applied your suggested wording and fixed the broken link in the suggestion to use the relative path. |
07ab28a to
84eb11c
Compare
|
Hi @dipikabh @hamishwillee, just a gentle nudge to see if you've had a chance to look at the latest updates. I've addressed the feedback regarding the 'queuing a task' terminology. All checks are passing. Thanks! |
|
Preview URLs (1 page) |
|
Thank you @oldregime As @dipikabh points out, this particular text is already being worked on and has been in discussion for a while. It would be wrong for us to just accept our text - I should have checked this was not a duplicate before reviewing. I have copied the suggested text and our reasoning to https://github.com/mdn/content/pull/43521/changes#r3186206543 |
Summary
dispatchEvent()invokes applicable handlers synchronouslyIssue
Fixes #43519
Checks
npx --yes prettier -c files/en-us/web/api/eventtarget/dispatchevent/index.mdgit diff --checkNote: a standalone
markdownlint-cli2run without the full repo lint config reported pre-existing line-length findings in this page.