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

Function simulateNoScrollEndSupport

lib/hooks/useIsScrolling.test.ts:19–37  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17
18 // Remove the event handler property (from whichever prototype defines it) for browsers without scrollend support
19 function simulateNoScrollEndSupport() {
20 let owner: object | null = window;
21 while (
22 owner &&
23 !Object.prototype.hasOwnProperty.call(owner, "onscrollend")
24 ) {
25 owner = Object.getPrototypeOf(owner);
26 }
27 if (!owner) {
28 return;
29 }
30
31 const descriptor = Object.getOwnPropertyDescriptor(owner, "onscrollend")!;
32 // @ts-expect-error Simulate the property being unsupported
33 delete owner.onscrollend;
34 onTestFinished(() => {
35 Object.defineProperty(owner, "onscrollend", descriptor);
36 });
37 }
38
39 test("should be false until the target scrolls", () => {
40 const { result } = renderHook(() => useIsScrolling(createElement()));

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected