-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Early queueMicroTask
execution in relation to MutationObserver
#924
Comments
Interesting, because here it should be based on |
Yes, here microtask is based on |
Not 100% sure how this is supposed to work either; but if I read https://jakearchibald.com/2015/tasks-microtasks-queues-and-schedules/#whos-right correctly (click through the interactive example), the code above should be roughly equivalent to: document.body.append('');
queueMicrotask(() => {
console.log("first");
});
queueMicrotask(() => {
console.log("second");
}); And I get the same issue with the following code using a Promise instead of new MutationObserver(() => {
console.log("first");
}).observe(document.body, { childList: true });
document.body.append('');
Promise.resolve().then(() => {
console.log("second");
}); The use case is that I want to be sure that MutationObserver callbacks have been run after adding a node to the DOM, and I thought that I could do this with |
If I force it to use the Promise-based polyfill in |
Yes, I remember this post. But you could imagine it as 2 separate microtask queues. I don't think that it somehow contradicts that. Why it's called before your callback - in |
Similar example to the one in #855:
Which produces
first
,second
in the latest Chrome and Firefox, butsecond
,first
in Firefox 68 ESR.The text was updated successfully, but these errors were encountered: