Conversation
infra.bs
Outdated
| <dfn export for=list/slice><var>to</var></dfn> (default |list|'s <a for=list>size</a>), is to create a new | ||
| <a>list</a> |slice|, of the same designation, and <a for=list>append</a> each | ||
| <a for=list>item</a> of |list|, where the index is greater than or equal to |from| and less than | ||
| |to|, to |slice|, maintaining order. |
There was a problem hiding this comment.
I think we should make this a list of steps for clarity. That way we can also assert the obvious things about from and to.
There was a problem hiding this comment.
Yeah that's fair.
Are you ok with clone being defined in terms of slice?
There was a problem hiding this comment.
Yeah that seems good. Always nice to have fewer fundamental primitives.
| <li><p>If |from| is less than 0, then set |from| to 0. | ||
|
|
||
| <li><p>If |to| is greater than |list|'s <a for=list>size</a>, then set |to| to |list|'s <a for=list>size</a>. |
There was a problem hiding this comment.
I felt this was preferable to asserting. It means, like in JS, you can slice from 0 to 100 to 'crop' a list to maximum of 100 items.
['foo'].slice(0, 100); // does not throw| <li><p>If |from| is less than 0, then set |from| to 0. | ||
|
|
||
| <li><p>If |to| is greater than |list|'s <a for=list>size</a>, then set |to| to |list|'s <a for=list>size</a>. |
There was a problem hiding this comment.
Is this needed for specifications? I might not be considering all scenarios that well, but I was assuming we'd just want to require both of these to be within bounds of the list.
For whatwg/html#12345.
I also changed the definition of clone, since it's just a slice with default args.