You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 2-ui/2-events/05-dispatch-events/article.md
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -241,20 +241,20 @@ Please note that the nested event `menu-open` bubbles up and is handled on the `
241
241
242
242
That's not only about `dispatchEvent`, there are other cases. JavaScript in an event handler can call methods that lead to other events -- they are too processed synchronously.
243
243
244
-
If we don't like it, we can either put the `dispatchEvent` (or other event-triggering call) at the end of `onclick` or, if inconvenient, wrap it in `setTimeout(...,0)`:
244
+
If we don't like it, we can either put the `dispatchEvent` (or other event-triggering call) at the end of `onclick` orwrap it in zero-delay `setTimeout`:
@@ -263,6 +263,8 @@ If we don't like it, we can either put the `dispatchEvent` (or other event-trigg
263
263
</script>
264
264
```
265
265
266
+
Now `dispatchEvent` runs asynchronously after the current code execution is finished, including `mouse.onclick`, so event handlers are totally separate.
267
+
266
268
## Summary
267
269
268
270
To generate an event, we first need to create an event object.
0 commit comments