简体   繁体   English

如何理解规范的事件循环中未由任务队列调度的事件?

[英]How to understand the event which not dispatched by task queue in event loop of spec?

In the spec :规范中

Not all events are dispatched using the task queue, many are dispatched during other tasks.并非所有事件都使用任务队列调度,许多事件是在其他任务期间调度的。

I want to know the "many" and the "other tasks" above refer to what?我想知道上面的“许多”和“其他任务”指的是什么?

If you search the HTML spec for the phrase “fire an event” , you'll see cases it says “queue a task to fire an event” and places it just says ”fire an event“ without “queue a task” .如果你在 HTML 规范中搜索短语“fire an event” ,你会看到这样的例子它说“queue a task to fire an event”,并放置它只是说“fire an event”而不是“queue a task” For example : 例如

Each document has a current document readiness .每个文档都有一个当前的文档准备情况 … When the value is set, the user agent must fire an event named readystatechange at the Document object . … 当该值被设置时,用户代理必须在Document对象上触发一个名为readystatechange的事件

Compare that language above to the language in the following spec excerpt :将上述语言与以下规范摘录中的语言进行比较:

… the user agent must, if the loads were successful, queue a task to fire an event named load at the link element ...用户代理必须,如果加载成功,则将任务排队以在link元素处触发名为load的事件...

So when the spec instead of saying “queue a task to fire an event” just says “fire an event”, then the event doesn't go into the task queue but instead must essentially be fired synchronously.因此,当规范而不是说“将任务排入队列以触发事件”而只是说“触发事件”时,则该事件不会进入任务队列,而是本质上必须同步触发。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 引入事件循环优先于任务队列的单独微任务队列的动机是什么? - What was the motivation for introducing a separate microtask queue which the event loop prioritises over the task queue? 浏览器中的事件循环和任务队列之间有区别吗? - Is there a difference between event loop and task queue in browsers? Javascript事件循环任务队列可能溢出吗? - Is Javascript event loop task queue overflow possible? 如何调度已经在javascript中调度的事件? - how to dispatch an event which has already been dispatched in javascript? 哪个任务(setTimeout 或点击事件)在任务队列中被优先处理? - Which task(setTimeout or click event) is prioritized in the task queue? 如何处理由Firefox插件调度的事件? - How to handle an event dispatched by a Firefox add-on? 事件队列和任务队列之间有什么区别吗? - Is there any difference between event queue and task queue? chrome事件未调度 - chrome Event is not dispatched 浏览器中的事件循环如何同时处理事件队列、作业队列、渲染队列? - How does the event loop in the browser deal with the event queue, job queue, render queue at the same time? JavaScript 事件循环:队列 vs 消息队列 vs 事件队列 - JavaScript Event Loop: Queue vs Message Queue vs Event Queue
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM