W3C home > Mailing lists > Public > public-css-archive@w3.org > June 2018

Re: [csswg-drafts] [web-animations-1] Should async playback methods return the `ready` Promise?

From: Brian Birtles via GitHub <sysbot+gh@w3.org>
Date: Wed, 20 Jun 2018 08:19:10 +0000
To: public-css-archive@w3.org
Message-ID: <issue_comment.created-398665201-1529482749-sysbot+gh@w3.org>
Having merged this and begun to implement I am concerned that this will make the API harder to use due to "Unhandled Promise rejection" warnings (and errors in some frameworks).

In particular, consider the following code:

button.onClick(() => {
// ...

If the click occurs while the animation is still pause-pending we'll get a unhandled Promise rejection, which, at very least, will clutter up the console. 

Instead the author needs to write:

animation.pause().catch(() => { /* Ignore */ });

or `try { } catch (e) { }` if they are using `async/await`.

This is even more likely in the case of `play()` where if the animation is aborted any time before it finishes the returned Promise will be rejected. Fortunately it does not affect `Element.animate()`.

I'm not sure if there's any way around this. If anyone knows, please let me know.

GitHub Notification of comment by birtles
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/2206#issuecomment-398665201 using your GitHub account
Received on Wednesday, 20 June 2018 08:19:15 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:25:04 UTC