if a pseudo-elememt covers a point, why can elementFromPoint returns its parent element…
- User
if a pseudo-elememt covers a point, why can elementFromPoint returns its parent element when the pseudo-element isn't in DOM
Assistant
That's a great observation!
document.elementFromPoint()returns the parent element when a pseudo-element covers a point because pseudo-elements are not actual DOM nodes - they're purely presentational and are rendered as part of their parent element's box model.Think of it this way: When the browser renders the page, it creates a visual layer for pseudo-elements, but from the DOM's perspective, that visual content is just part of the parent element's rendering.
elementFromPoint()operates on the DOM structure, not the visual rendering layers.This is similar to how
elementFromPoint()would handle text nodes or background images - it returns the containing element, not the specific visual content at that point.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.