[csswg-drafts] [css-highlight-api] Exposing shadow DOM highlights in highlightsFromPoint() (#7766)

dandclark has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-highlight-api] Exposing shadow DOM highlights in highlightsFromPoint() ==
The `highlightsFromPoint()` function, discussed [here](https://github.com/w3c/csswg-drafts/issues/7513#issuecomment-1248320696), should probably not return highlights in shadow DOMs by default. But, there should still be a way for authors to allow interaction with highlights in shadows using `highlightsFromPoint()`.

I can think of two ways to have this function expose shadow DOM highlights.

The first is to handle it like `getInnerHTML()` does for Declarative Shadow DOM, in which it takes an `includeShadowRoots` option as well as a list of closed shadow roots. Highlights inside those shadows can be returned without breaking encapsulation, sinc the caller has proven that they already know about them: https://web.dev/declarative-shadow-dom/#serialization. Highlights could do something similar:

```js
const hitTestResults = CSS.highlights.highlightsFromPoint({
  includeShadowRoots: true,
  closedRoots: [shadowRoot1, shadowRoot2, ...]
});
```

Alternatively, we could put `highlightsFromPoint()` on [DocumentOrShadowRoot](https://dom.spec.whatwg.org/#mixin-documentorshadowroot). When called on a Document, it would return only highlights in that document (not in its shadow roots). When called on a shadow root, it would return only highlights in that shadow, or perhaps highlights in that shadow plus highlights in the document (but not highlights in any nested shadow roots). This is analogous to how `elementsFromPoint()` works in Blink and Gecko today, though the [spec](https://drafts.csswg.org/cssom-view/#dom-document-elementsfrompoint) doesn't yet reflect that `elementsFromPoint()` is callable on shadow DOM and I see some cross-browser inconsistencies in which elements are returned.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7766 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Monday, 19 September 2022 16:51:18 UTC