Add getComputedStyle helper to ViewTransition refs (#32751)

This is also sometimes useful to read the style of the pseudo-element
itself without an animation.
This commit is contained in:
Sebastian Markbåge 2025-03-26 15:02:53 -04:00 committed by GitHub
parent fceb0f80bc
commit f134b3993a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2085,6 +2085,7 @@ export function stopViewTransition(transition: RunningViewTransition) {
interface ViewTransitionPseudoElementType extends Animatable {
_scope: HTMLElement;
_selector: string;
getComputedStyle(): CSSStyleDeclaration;
}
function ViewTransitionPseudoElement(
@ -2138,6 +2139,14 @@ ViewTransitionPseudoElement.prototype.getAnimations = function (
}
return result;
};
// $FlowFixMe[prop-missing]
ViewTransitionPseudoElement.prototype.getComputedStyle = function (
this: ViewTransitionPseudoElementType,
): CSSStyleDeclaration {
const scope = this._scope;
const selector = this._selector;
return getComputedStyle(scope, selector);
};
export function createViewTransitionInstance(
name: string,