[cssom] Allow passing a callback to `window.getComputedStyle(…)`
Nobody has claimed this yet.
- Dominant language
- Bikeshed
- Stars
- 4.9k
- Forks
- 816
- PR merge metrics
- PR metrics pending
Description
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.
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:
// 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);
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read the CSSOM getComputedStyle section at the linked specification URL and compare it with the proposed overloads in the issue. Determine the standards behavior and compatibility requirements for the callback form. Done means the Working Draft reflects an agreed callback API and its legacy-browser behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- css, javascript
- Domain
- frontend, web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100