I have a website I’m working on where there is an iframe which calls document.elementFromPoint in a loop in an event handler a bunch of times. I did a performance snapshot of the code and saw something strange.
It seems like hit test, which is a internal browser thing, is calling my anonymous event handler which is calling element from point. But this doesn’t make any sense. It should be that my event handler is calling elementFromPoint which then should be calling hit test, assuming hit test is what is internally used in elementFromPoint. Also I don’t see why there seem to be gaps in the main thread.
Can anyone explain why this is happening?
- The Iframe has same origin
- document.elementFromPoint is getting svg elements
What I have found.
- When the loop is not so long the order is correct, my code calls elementfrompoint calls hit test.
- Long loops seem to cause the issue