addEventListener的回调函数在Event Loop的宏任务队列中排队?

the callback function of addEventListener is queued in macro task queue in Event Loop?

我知道setTimeoutsetIntervalsetImmediateapi的回调函数在宏任务队列中排队

但是,我不确定 addEventListener

addEventListener的回调函数是否在宏任务队列中排队?

请检查:D

I know that the callback function of setTimeout, setInterval, setImmediate api is queued in macro task queue.

不是。计时器 task-queue 中排队的是一个 task. This task's steps will be responsible of executing the callbacks (through the fire an event 算法)。回调本身存储在内存中。
对于事件侦听器,情况大致相同,事件回调从不在任务源中排队,只有任务或微任务在排队,并且作为这些任务步骤的一部分,事件被分派并执行回调。

例如,您可以很好地从微任务中触发事件(例如 slotchange event, but you can also force it yourself with EventTarget#dispatchEvent()), most native events are generally part of task (just search for the phrase to fire an event in the HTML specs for examples), and you have loads of events that don't fire from any tasks nor microtask, but directly as part of the event loop processing, in the update the rendering 步骤。