Skip to content

Commit fc3b140

Browse files
Copilotmattcosta7
andcommitted
Improve comment clarity on getComputedStyle call counting
Co-authored-by: mattcosta7 <8616962+mattcosta7@users.noreply.github.com>
1 parent d861210 commit fc3b140

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

src/__tests__/anchored-position.test.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -434,20 +434,22 @@ describe('getAnchoredPosition', () => {
434434
expect(result.left).toBeDefined()
435435

436436
// With the optimization, we should make:
437-
// - 1 call for each intermediate div (5 calls total during traversal)
438-
// - 1 call for root (positioned parent and clipping node found in one traversal)
439-
// - 1 call for the positioned parent to get its borders
440-
// - 1 call for the clipping node to get its borders
437+
// - 5 calls during traversal (one for each intermediate div)
438+
// - 1 call for root during traversal (finds both positioned parent and clipping node)
439+
// - 1 call in getClippingRect for root's borders
440+
// - 1 call for positioned parent's borders (root again, but separate call)
441441
// Total: 5 + 1 + 1 + 1 = 8 calls
442+
// Note: Even though root is both positioned parent and clipping node, we make 2 separate
443+
// calls for it after traversal (one for clipping rect, one for parent borders)
442444
//
443445
// Without optimization it would be:
444-
// - 6 calls for getPositionedParent (5 intermediate + 1 root)
446+
// - 6 calls for getPositionedParent traversal (5 intermediate + 1 root)
445447
// - 6 calls for getClippingRect traversal (5 intermediate + 1 root)
446448
// - 1 call for positioned parent borders
447-
// - 1 call for clipping rect borders
448-
// Total: 14 calls
449+
// - 1 call for clipping rect borders (same element but separate call)
450+
// Total: 6 + 6 + 1 + 1 = 14 calls
449451
//
450-
// The exact count depends on implementation details, but it should be significantly less
452+
// Optimization reduces calls from 14 to 8 (42% reduction)
451453
expect(callCount).toBeLessThan(14)
452454
expect(callCount).toBeGreaterThan(0)
453455

0 commit comments

Comments
 (0)