Re: [w3c/selection-api] Flat Tree or Composed Tree (Issue #336)

I did an audit of the existing Selection API that uses DOM tree traversal and where a Flat tree traversal would be more useful and visual:
* Selection::setBaseAndExtent
* Range::setStart/setStartBefore/setStartAfter
* Range::setEnd/setEndAfter/setEndBefore
* Range::isPointInRange
* Range::comparePoint/compareBoundaryPoints
* Range::intersectsNode
* Range::commonAncestorContainer

Specifically, for Selection::setBaseAndExtent, I wrote out a proposal of how we can change/add to the existing API to allow a flat tree position comparison to set the base and extent:
https://github.com/dizhang168/shadow-dom-selection/blob/main/flat-tree-setBaseAndExtent.md
I added examples for various slot cases to show the different output for DOM/Composed vs Flat Tree traversal.

If we go with proposal 2, then maybe we should have this project separated from the getComposedRanges() API because indeed it affects the Selection definition, not just how to get endpoints inside a shadow tree.

We should also reach out to Editor authors to better understand their pain points with slots.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/selection-api/issues/336#issuecomment-2397631261
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/selection-api/issues/336/2397631261@github.com>

Received on Monday, 7 October 2024 18:42:03 UTC