@samitouri / QOS-React / commits / f134b3993a

Add getComputedStyle helper to ViewTransition refs (#32751)

This is also sometimes useful to read the style of the pseudo-element itself without an animation.

Sebastian Markbåge committed Mar 26, 2025 at 15:02 UTC f134b3993a84d53cc99fe66b426ba13548f142ec
1 file changed +9
packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
+9
@@ -2085,6 +2085,7 @@ export function stopViewTransition(transition: RunningViewTransition) {
2085 interface ViewTransitionPseudoElementType extends Animatable {
2086 _scope: HTMLElement;
2087 _selector: string;
2088 + getComputedStyle(): CSSStyleDeclaration;
2089 }
2090
2091 function ViewTransitionPseudoElement(
@@ -2138,6 +2139,14 @@ ViewTransitionPseudoElement.prototype.getAnimations = function (
2139 }
2140 return result;
2141 };
2142 +// $FlowFixMe[prop-missing]
2143 +ViewTransitionPseudoElement.prototype.getComputedStyle = function (
2144 + this: ViewTransitionPseudoElementType,
2145 +): CSSStyleDeclaration {
2146 + const scope = this._scope;
2147 + const selector = this._selector;
2148 + return getComputedStyle(scope, selector);
2149 +};
2150
2151 export function createViewTransitionInstance(
2152 name: string,