Open dandclark opened 1 year ago
I could note there is https://github.com/mfreed7/declarative-shadow-dom/issues/9
The CSS Working Group just discussed [css-highlight-api] Exposing shadow DOM highlights in highlightsFromPoint()
, and agreed to the following:
RESOLVED: Change highlights from point to work on document or shadow root with the intention of synchronizing how highlights and elements from point work. Open a new issue to harmonize the specs and doing the research
Hi all, we propose putting highlightsFromPoint()
on CSS.highlights
, not DocumentOrShadowRoot
, and adding an optional options
dictionary parameter to the API. This dictionary has a key that maps to an array of ShadowRoot
objects that can return highlights.
This approach is similar to how document.caretPositionFromPoint()
and getHTML()
interact with shadow DOM. Please let us know if there are any questions or concerns - thanks!
cc: @sanketj
@dandclark @tabatkins Does Stephanie's proposed syntax change seem reasonable to you?
Yes, I think it's a reasonable change given the similarity to document.caretPositionFromPoint().
@astearns Do you think we can resolve async on the updates that @stephanieyzhang proposed here? There are deltas compared to what the working group has resolved on previously, but I think they are relatively minor.
The CSSWG will automatically accept this resolution one week from now if no objections are raised here. Anyone can add an emoji to this comment to express support. If you do not support this resolution, please add a new comment.
Proposed Resolution: The highlightsFromPoint()
method will be added to CSS.highlights
, and have an optional options
dictionary parameter matching the one from caretPositionFromPoint()
RESOLVED: The highlightsFromPoint()
method will be added to CSS.highlights
, and have an optional options
dictionary parameter matching the one from caretPositionFromPoint()
The
highlightsFromPoint()
function, discussed here, 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 usinghighlightsFromPoint()
.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 anincludeShadowRoots
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:Alternatively, we could put
highlightsFromPoint()
on 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 howelementsFromPoint()
works in Blink and Gecko today, though the spec doesn't yet reflect thatelementsFromPoint()
is callable on shadow DOM and I see some cross-browser inconsistencies in which elements are returned.