Meet Selection.getComposedRanges() πŸ†•

Unlike getRangeAt(), it returns selection ranges across Shadow DOM boundaries, essential for modern web components.

Since August 2025, this feature is Baseline.

Learn how it works πŸ‘‡
https://developer.mozilla.org/en-US/docs/Web/API/Selection/getComposedRanges