You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Make setBaseAndExtent and other setter methods on Selection work with shadow DOM #99
Per WICG/webcomponents#79, we should make setBaseAndExtent and other methods work with shadow DOM. Namely, when a node inside a shadow tree is given to setBaseAndExtent, it shouldn't throw or adjust the end points to be in the same tree.
No, it's not exposed. It's just that these setter functions need to allow referencing into nodes within shadow trees. Getters will continue to return the outer most host.
Selection.extend has the similar issue and it seems that browsers work differently.
However, I think the spec can allow to specify a point in different subtree root point with a pair of the container and the offset in it, but cannot allow to specify a point in a flattened tree specific point.
For example, if a node is assigned to a <slot>, specifying the point should be the parent node of the node and offset of the node in the non-flattened tree rather than <slot> and index in the assigned node list. Otherwise, the implementations cannot distinguish whether the API caller intended a point in the flattened tree or the non-flattened tree.
Similarly, the shadow host and an offset should not be treated as the shadow root and the offset in it.
So, the spec needs to define the logic from a point in the non-flattened tree to one in the flattented tree.
Activity
rniwa commentedon Jul 20, 2023
At least collapse working with shadow DOM is a web compatibility requirement at this point:
WebKit/WebKit@c48d719
annevk commentedon Jul 25, 2023
Hmm, so when a shadow tree child is selected it's exposed through a global API? That seems rather bad.
rniwa commentedon Jul 25, 2023
No, it's not exposed. It's just that these setter functions need to allow referencing into nodes within shadow trees. Getters will continue to return the outer most host.
masayuki-nakano commentedon Feb 4, 2026
Selection.extendhas the similar issue and it seems that browsers work differently.However, I think the spec can allow to specify a point in different subtree root point with a pair of the container and the offset in it, but cannot allow to specify a point in a flattened tree specific point.
For example, if a node is assigned to a
<slot>, specifying the point should be the parent node of the node and offset of the node in the non-flattened tree rather than<slot>and index in the assigned node list. Otherwise, the implementations cannot distinguish whether the API caller intended a point in the flattened tree or the non-flattened tree.Similarly, the shadow host and an offset should not be treated as the shadow root and the offset in it.
So, the spec needs to define the logic from a point in the non-flattened tree to one in the flattented tree.
However, there is a problem, I tried to write the conversion for the internal use in Gecko, but there are probably 2 intentions about the offset. One is specifying after the previous child of the child at offset. The other is specifying the child at the offset directly. Currently, Gecko assumes the former if the point is collapsed or end boundary of a range and the latter if the point is start boundary of a range.
https://searchfox.org/firefox-main/rev/c206271d981e72dac0fdd91625b2c0709129a7d6/dom/base/RangeBoundary.h#349-387