Skip to content

Commit

Permalink
feat: [#1400] Adds support for document.elementFromPoint
Browse files Browse the repository at this point in the history
Co-authored-by: David Ortner <david@ortner.se>
  • Loading branch information
TreyVigus and capricorn86 committed May 6, 2024
1 parent 2e03291 commit 4dc3de4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/happy-dom/src/nodes/document/Document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1349,6 +1349,17 @@ export default class Document extends Node {
return processingInstruction;
}

/**
* Get element at a given point.
*
* @param _x horizontal coordinate
* @param _y vertical coordinate
* @returns Always returns null since Happy DOM does not render elements.
*/
public elementFromPoint(_x: number, _y: number): Element | null {
return null;
}

/**
* Imports a node.
*
Expand Down
7 changes: 7 additions & 0 deletions packages/happy-dom/test/nodes/document/Document.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1409,4 +1409,11 @@ describe('Document', () => {
expect(document.currentScript).toBe(null);
});
});

describe('elementFromPoint', () => {
it('Returns null.', () => {
const element = document.elementFromPoint(0, 0);
expect(element).toBe(null);
});
});
});

0 comments on commit 4dc3de4

Please sign in to comment.