From dadfaacfd30fc152ff18df9b2d7ec2ab9f9ce84e Mon Sep 17 00:00:00 2001 From: Sebastian Markbage Date: Tue, 25 Mar 2025 18:57:02 -0400 Subject: [PATCH] Add getComputedStyle helper to ViewTransition refs This is also sometimes useful to read the style of the pseudo-element itself without an animation. --- .../react-dom-bindings/src/client/ReactFiberConfigDOM.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js index f01817ce240fd..80ff04bda3ee3 100644 --- a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js +++ b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js @@ -2079,6 +2079,7 @@ export function stopGestureTransition(transition: RunningGestureTransition) { interface ViewTransitionPseudoElementType extends Animatable { _scope: HTMLElement; _selector: string; + getComputedStyle(): CSSStyleDeclaration; } function ViewTransitionPseudoElement( @@ -2132,6 +2133,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,