@@ -5,6 +5,7 @@ import { ReactScanInternals } from '../index';
55import { getLabelText } from '../utils' ;
66import { isOutlineUnstable , throttle } from './utils' ;
77import { log } from './log' ;
8+ import { recalcOutlineColor } from './perf-observer' ;
89// import { recalcOutlineColor } from './perf-observer';
910
1011export interface PendingOutline {
@@ -38,19 +39,7 @@ export const getOutlineKey = (outline: PendingOutline): string => {
3839 return `${ outline . rect . top } -${ outline . rect . left } -${ outline . rect . width } -${ outline . rect . height } ` ;
3940} ;
4041
41- const getRectCache = new WeakMap <
42- HTMLElement ,
43- { rect : DOMRect ; timestamp : number }
44- > ( ) ;
45-
4642export const getRect = ( domNode : HTMLElement ) : DOMRect | null => {
47- const cachedRect = getRectCache . get ( domNode ) ;
48- if (
49- cachedRect &&
50- performance . now ( ) - cachedRect . timestamp < DEFAULT_THROTTLE_TIME
51- ) {
52- return cachedRect . rect ;
53- }
5443 const style = window . getComputedStyle ( domNode ) ;
5544 if (
5645 style . display === 'none' ||
@@ -63,17 +52,15 @@ export const getRect = (domNode: HTMLElement): DOMRect | null => {
6352 const rect = domNode . getBoundingClientRect ( ) ;
6453
6554 const isVisible =
66- rect . top >= 0 ||
67- rect . left >= 0 ||
68- rect . bottom <= window . innerHeight ||
55+ rect . top >= 0 &&
56+ rect . left >= 0 &&
57+ rect . bottom <= window . innerHeight &&
6958 rect . right <= window . innerWidth ;
7059
7160 if ( ! isVisible || ! rect . width || ! rect . height ) {
7261 return null ;
7362 }
7463
75- getRectCache . set ( domNode , { rect, timestamp : performance . now ( ) } ) ;
76-
7764 return rect ;
7865} ;
7966
@@ -168,7 +155,7 @@ export const flushOutlines = (
168155
169156 requestAnimationFrame ( ( ) => {
170157 if ( perfObserver ) {
171- // recalcOutlineColor(perfObserver.takeRecords());
158+ recalcOutlineColor ( perfObserver . takeRecords ( ) ) ;
172159 }
173160 recalcOutlines ( ) ;
174161 void ( async ( ) => {
0 commit comments