[csswg-drafts] [web-animations-1] Ordering of promises and events, and where events are fired (#5582)

jakearchibald has just created a new issue for https://github.com/w3c/csswg-drafts:

== [web-animations-1] Ordering of promises and events, and where events are fired ==
There seems to be some confusion around the ordering of promises and events in the spec.

https://github.com/web-platform-tests/wpt/blob/master/web-animations/interfaces/Animation/onfinish.html#L30 - the first test assumes the promise callbacks happen before the equivalent event (other tests may too).

https://drafts.csswg.org/web-animations-1/#updating-the-finished-state - the promise is 'resolved' before a task is queued to dispatch the event, which could be read as "promise resolves first", but the timing is unclear as no task is queued to perform the resolving.

The timing is important here, since it's expected to synchronise with rendering.

The animation spec probably shouldn't queue tasks to dispatch events at all. Since they're related to rendering, they should be part of [animation events](https://drafts.csswg.org/web-animations/#animation-events), which has a particular step in the [rendering part of the event loop](https://html.spec.whatwg.org/multipage/webappapis.html#event-loop-processing-model) (11.10). This would also clarify the ordering of CSS animations/transitions vs web animations. 

The event and promise should happen at the 'same time' from the developer's perspective. Since event dispatch is synchronous, and promise callbacks are asynchronous, this means all event listeners should be called before any 'same' promise callbacks. I've asked for some clarification on this in the promises guide https://github.com/w3ctag/promises-guide/issues/71.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/5582 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Monday, 5 October 2020 07:58:31 UTC