What is the issue with the HTML Standard?
We have (at least) two places in the HTML standard where we explicitly wrap some operation in a script prepare/cleanup pair:
- The navigation API
- when activating a view transition during page reveal.
This feels unintuitive and edge-casey, and makes it harder to explain how microtasks work.
The issue at the core of (1) is to make sure all the promises are fired after all the events.
The issue at the core of (2), is that calling the promise resolution algorithm queues a microtask, and that microtask would only resolve either when some unrelated event handler or callback is called, or after painting (end of the rendering task).
There might be a better way to explain this, e.g. split those complex task to "stages" where each stage runs its own checkpoint, or as a "task that is actually a chain of multiple tasks" or something to that effect.
Open to suggestions and discussion.