@@ -648,6 +648,7 @@ export type FragmentInstanceType = {
648648 getRootNode ( getRootNodeOptions ?: {
649649 composed : boolean ,
650650 } ) : Node | FragmentInstanceType ,
651+ getClientRects : ( ) => Array < DOMRect > ,
651652} ;
652653
653654function FragmentInstance ( this : FragmentInstanceType , fragmentFiber : Fiber ) {
@@ -772,6 +773,27 @@ FragmentInstance.prototype.getRootNode = function (
772773 return rootNode ;
773774} ;
774775
776+ // $FlowFixMe[prop-missing]
777+ FragmentInstance . prototype . getClientRects = function (
778+ this : FragmentInstanceType ,
779+ ) : Array < DOMRect > {
780+ const rects : Array < DOMRect > = [ ] ;
781+ traverseFragmentInstance ( this . _fragmentFiber , collectClientRects , rects ) ;
782+ return rects ;
783+ } ;
784+ function collectClientRects(child: Fiber, rects: Array< DOMRect > ): boolean {
785+ const instance = getPublicInstanceFromHostFiber ( child ) ;
786+
787+ // getBoundingClientRect is available on Fabric instances while getClientRects is not.
788+ // This should work as a substitute in this case because the only equivalent of a multi-rect
789+ // element in RN would be a nested Text component.
790+ // Since we only use top-level nodes here, we can assume that getBoundingClientRect is sufficient.
791+ // $FlowFixMe[method-unbinding]
792+ // $FlowFixMe[incompatible-use] Fabric PublicInstance is opaque
793+ rects . push ( instance . getBoundingClientRect ( ) ) ;
794+ return false ;
795+ }
796+
775797export function createFragmentInstance(
776798 fragmentFiber: Fiber,
777799): FragmentInstanceType {
0 commit comments