Re: [whatwg/dom] Proposal: RangeList (#543)

Quick aesthetics hints/brainstorming:

### intersections

Since two ranges can reach same nodes, but ranges can be only consecutive list of nodes, these would be the rules:

  * range A ends with nodes at the beginning of range B as in `[1, 2, 3]` and `[3, 4, 5]`. All operations are performed over `[1, 2, 3, 4, 5]`
  * range A includes range B, as in `[1, 2, 3, 4, 5]` and `[2, 3, 4]`, all operations are performed over range A
  * range A starts with nodes in range B, as in `[3, 4, 5]` and `[1, 2, 3]`, all operations are performed over `[3, 4, 5, 1, 2]`
  * range A does not have any range B node, as in `[1, 2, 3]` and `[5, 6, 7]`, all operations are performed over `[1, 2, 3, 5, 6, 7]`

### Methods (for a useful MVP)

  * `cloneContents()` will clone once every node selected in each range
  * `deleteContents()` will remove once every node selected in each range
  * `extractContents()` will remove and put in the returned fragment every node selected in each range

### as RangeList

Immutable, with a mandatory iterable during constructor as in `new RangeList(iterable)`.

The `iterable` will be, as example, an `Array` of ranges.

### as RangeSet

Mutable, with all `Set` methods.

```js
const rs = new RangeSet;
rs.add(range1);
if (!rs.has(range2)) rs.add(range2);
rs.delete(range3);
```
- - -

Thanks for consideration.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/543#issuecomment-349947437

Received on Thursday, 7 December 2017 12:01:29 UTC