[whatwg/dom] async disconnectedCallback? (#705)

I couldn't find any information in the spec about whether `connectedCallback` and `disconnectedCallback` lifecycle hooks support promises or not. But I'd like to do things asynchronously before a component is removed from the DOM. Let's assume I have a custom element that represents a page within my application. I'd like to be able to fade the page out before it disconnects.

```js
 class MyPage extends HTMLElement {
    async disconnectedCallback() {
        const animation = this.animate([
                { opacity: 1},
                { opacity: 0},
            ],
            {
                duration: 1500,
                fill: 'forwards',
            });
        return animation.finished;
    }
  }
```

As of right now, when the element is removed from the DOM, it does not wait for the promise I'm returning, so the fade out never happens.

Here is a working example:
https://stackblitz.com/edit/async-callbacks

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/705

Received on Sunday, 14 October 2018 13:48:55 UTC