[csswg-drafts] [cssom-view] Specify document.caretPositionFromPoint in shadow DOM scenario (#9932)

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

== [cssom-view] Specify document.caretPositionFromPoint in shadow DOM scenario ==
Current spec is vague about the behavior in shadow DOM: https://www.w3.org/TR/cssom-view-1/#dom-document-caretpositionfrompoint

Gecko's current behavior in shadow DOM:
The returned `CaretPosition`'s `offset` is the text offset of the hit tested text node and the `offsetNode` depends on the mode of the shadow tree:
  1. If the tree is created by user agent such as input element, the node is the shadow host.
  2. Otherwise, the node is the hit tested text node even if the tree is closed.

Gecko's existing behavior can address most of the need for web developers. Should we specify the behavior?

Or are there other alternatives that we should consider:
  1. `caretPositionFromPoint` do not pierce shadow DOM. Instead, put the API on `DocumentOrShadowRoot`.
  2. support closed shadow root with a new parameter: `document.caretPositionFromPoint(x, y, closedShadowRoot);`

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


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

Received on Friday, 9 February 2024 22:21:47 UTC