demo · v132

Live readout of selection.isCollapsed

Make a selection on the paragraph below — entirely in the light DOM, entirely in the shadow web component, or spanning the boundary. Watch the live readout: every selection event, every isCollapsed value.

checking support…
Light DOM text before light DOM text after — try selecting across the boundary using shift-arrow keys.

readout

selection.isCollapsed—live
selection.rangeCount—
selection.anchorNode—
selection.focusNode—
anchor === focus—
pre-v132 (anchorNode==focusNode at boundary)—bug

see also