Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cssom-view] Allow elementFromPoint and elementsFromPoint to traverse shadow roots #10992

Open
captainbrosset opened this issue Oct 2, 2024 · 2 comments

Comments

@captainbrosset
Copy link
Contributor

I recently asked on Mastodon if folks knew the element(s)FromPoint() methods and whether they'd want them to be able to traverse shadow roots: https://mas.to/@patrickbrosset/113236606097090887

Some replies to my "Do you wish it would across Shadow DOM boundaries "question:

In my use case, whether I want it to cross Shadow DOM boundaries would depend on how "thick" the custom elements are. If thin, I wouldn't care. If they encompassed too much in the page, then yeah I'd want a more fine-grained approach.

YES

ABSOLUTELY YES

I'm not sure whether it should cross shadow boundaries on its own. I could maybe see an option, so you had to do work to get through, but didn't need to write your own recursive method.

I think I’d want to be explicit about getting any element from within a shadow root, so maybe if there was an option to include shadow roots.

Absolutely yes! Eventually, it could be a parameter option, like document.elementsFromPoint({ composed: true }) or similar.

Note that caretPositionFromPoint already works this way: https://developer.mozilla.org/en-US/docs/Web/API/Document/caretPositionFromPoint#shadowroots

Also, during the TAG review for caretPositionFromPoint @LeaVerou said (w3ctag/design-reviews#949 (comment)):

I would reiterate that elementFromPoint() could also be expanded in the same way for consistency (and I suspect there are plenty of use cases for that too).

@kbabbitt
Copy link
Contributor

kbabbitt commented Oct 2, 2024

To clarify: Is the proposal to extend elementFromPoint / elementsFromPoint with an optional options parameter which can contain a list of shadowRoots, similar to what we added to caretPositionFromPoint?

@captainbrosset
Copy link
Contributor Author

To clarify: Is the proposal to extend elementFromPoint / elementsFromPoint with an optional options parameter which can contain a list of shadowRoots, similar to what we added to caretPositionFromPoint?

Correct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants