capricorn86 / happy-dom

A JavaScript implementation of a web browser without its graphical user interface
MIT License
3.09k stars 185 forks source link

elementFromPoint is not working #1400

Closed danieldongit closed 2 months ago

danieldongit commented 3 months ago

Describe the bug I am using vendor code that utilized the elementFromPoint function (Codemirror 6).

To Reproduce Reproduction will take setting up codemirror in a development environment along with a testing framework. Might be a bit of a process

Error Log

TypeError: root.elementFromPoint is not a function
posAtCoords node_modules/@codemirror/view/dist/index.js:3418:24
let doc = view.dom.ownerDocument;
let root = view.root.elementFromPoint ? view.root : doc;
let element = root.elementFromPoint(x, y);
capricorn86 commented 2 months ago

Thank you for reporting @danieldongit! :slightly_smiling_face:

As Happy DOM can't render the Elements, it doesn't know which element will be at the point, but it should be possible to add a method that just returns null.

public elementFromPoint(_x: number, _y: number): Element | null {
      return null;
}
TreyVigus commented 2 months ago

Working on a PR for this now

capricorn86 commented 2 months ago

Thank you for reporting @danieldongit! :slightly_smiling_face:

Big thanks to @TreyVigus for contributing with a fix :star:

https://github.com/capricorn86/happy-dom/releases/tag/v14.10.0