[csswg-drafts] [cssom] Allow passing a callback to `window.getComputedStyle` (#3579)

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

== [cssom] Allow passing a callback to `window.getComputedStyle` ==
https://drafts.csswg.org/cssom/#dom-window-getcomputedstyle

Right now, `window.getComputedStyle` is always executed synchronously.

By allowing the last parameter to be a callback, this function could be made asynchronous in a backwards compatible manner.

```ts
interface Window {
    getComputedStyle(elt: Element, pseudoElt?: string | null): CSSStyleDeclaration;
    getComputedStyle(elt: Element, callback: (result: CSSStyleDeclaration) => void): void;
    getComputedStyle(elt: Element, pseudoElt: string | null, callback: (result: CSSStyleDeclaration) => void): void;
}
```

The following assertion holds true for legacy browsers:
```js
// actual will only be undefined in modern browsers.
let actual = window.getComputedStyle(elt, function() {});
// expected will always be a CSSStyleDeclaration
let expected = window.getComputedStyle(elt);

// This works in legacy browsers:
assert.deepEqual(actual, expected);
```

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

Received on Thursday, 31 January 2019 13:44:39 UTC