[cssom-view] elementFromPoint and elementsFromPoint interop issues
Nobody has claimed this yet.
- Dominant language
- Bikeshed
- Stars
- 4.9k
- Forks
- 816
- PR merge metrics
- PR metrics pending
Description
Note: poorly defined might actually be better presented as incorrectly defined depending on your opinions on expected behaviour.
While working on tests for a new nodesFromRect() (see also https://github.com/w3c/csswg-drafts/issues/11605) I've discovered an interop issue with the existing functions of the same sort. Namely elementFromPoint and elementsFromPoint (I haven't explored further so it's possible this extends to other functions).
I added tests for what I interpreted expected behaviour to be but Emilio raised a counter argument, either way browsers are mostlly inconsistent between elementFromPoint and elementsFromPoint which suggests the spec is ambiguous.
To summarise handling of display:contents elements is inconsistent across browsers and between element and elementsFromPoint.
data:text/html,<div style="display:contents">Foobar</div><style>* {padding: 0;margin: 0;}</style><script>const x = document.elementFromPoint(5, 5);alert(x.tagName);const y = document.elementsFromPoint(5, 5);alert(y[0].tagName);</script>
In Chromium, WebKit, Firefox and Servo the first alert shows "DIV".
In WebKit the second alert also shows "DIV", but in the other 3 it shows "BODY".
Based on the spec text I don't think either of the functions should include the div because no box exists for a display:contents element. Emilio says that perhaps it should include the div because the text node gets hit tested and that's its parent, the spec currently doesn't mention "text sequences" for these functions though.
This issue is essentially to discuss what we actually want to happen and update the spec and tests to match accordingly.
Both I and Emilio agree that if an element is returned by the single function it should be included in the array one.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the CSSOM View behavior for elementFromPoint() and elementsFromPoint(), then review the display:contents cases and the tests in web-platform-tests PR 55253. Compare browser results and the existing spec wording; done means the expected behavior is decided and the specification and tests agree.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- css, javascript
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100