MCPcopy Create free account
hub / github.com/bvaughn/react-window / getRowBounds

Function getRowBounds

integrations/tests/tests/server-rendering.spec.tsx:6–35  ·  view source on GitHub ↗
(
  browser: Browser,
  url: string,
  { javaScriptEnabled }: { javaScriptEnabled: boolean }
)

Source from the content-addressed store, hash-verified

4// Rows are positioned using CSS transforms, which are not reported as layout shifts;
5// so compare server-rendered row positions (before hydration) to the hydrated positions directly
6async function getRowBounds(
7 browser: Browser,
8 url: string,
9 { javaScriptEnabled }: { javaScriptEnabled: boolean }
10) {
11 const context = await browser.newContext({ javaScriptEnabled });
12 const page = await context.newPage();
13
14 await page.goto(url);
15
16 if (javaScriptEnabled) {
17 // Wait for rows to be measured and re-positioned
18 await settle(page, { minFrames: 10 });
19 }
20
21 const bounds = await page.evaluate(() => {
22 const list = document.querySelector('[role="list"]')!;
23 const listTop = list.getBoundingClientRect().top;
24
25 return Array.from(list.querySelectorAll('[role="listitem"]')).map((row) => {
26 const { height, top } = row.getBoundingClientRect();
27
28 return { height, top: top - listTop };
29 });
30 });
31
32 await context.close();
33
34 return bounds;
35}
36
37test.describe("server-rendering", () => {
38 for (const [name, host] of [

Callers 2

GridComponentFunction · 0.85

Calls 1

settleFunction · 0.90

Tested by

no test coverage detected