Skip to content

Commit

Permalink
Merge pull request #54 from davidr64/prevent-calling-intersection-obs…
Browse files Browse the repository at this point in the history
…erver-for-empty-observers

Prevent enterAll and leaveAll from calling callbacks on observers with no observed nodes
  • Loading branch information
trurl-master committed Feb 26, 2024
2 parents 946c26f + 10b46f9 commit 9a36419
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/mocks/intersection-observer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ export class MockedIntersectionObserver implements IntersectionObserver {
}

triggerNodes(nodeDescriptions: NodeIntersectionDescription[]) {
if (nodeDescriptions.length === 0) return;

const nodeIndexes = nodeDescriptions.map(({ node }) =>
findNodeIndex(this.nodes, node)
);
Expand Down

0 comments on commit 9a36419

Please sign in to comment.