(#2497) - fix attachments in Chrome and IE

Yes, this is really what we have to do to get it to pass in IE. I'm sorry.
Even better:

```js
begin = Math.min(len, Math.max(0, begin));
end = Math.min(len, Math.max(0, end));
```