tmpvar/jsdom — pull request #804 by sjelin (2014-06-24 01:17:39+00:00)
Title: Text Selection API for Input and TextArea

See #799. Followed documentation at http://www.whatwg.org/specs/web-apps/current-work/#textFieldSelection

Pretty straight forward addition. A few concerns:

1. I ended up duplicating the code in order to put it into both Input and Text Area
2. When the content of the text box changes, presumably the selection is also supposed to change. Consider, for example, if the content of the box is empties, and the selection is supposed to be of characters 4 through 10. Clearly that selection is now impossible. However, I couldn't really find any documentation on this point (though it's possible I don't know where to look). Chrome moves the cursor to the end of the text box, which seems reasonable, but since I couldn't find it actually documented anywhere I just did some basic sanitizing to make sure the selection is always within the bounds of the actual text.
3. Sometimes `input` tags don't support the selection API (e.g. `type=radio`). In these cases I throw `throw new core.DOMException(core.INVALID_STATE_ERR)`, because chrome throws an `InvalidStateError` and this was the most similar thing I could find. No idea if that's the correct thing to throw though. Would appreciate someone who knows more taking a look.
4. On my machine, the automated tests stall at `running jsdom/index.js jsdom/index`. They did this before I made my changes, so I'm pretty sure it's not my fault, but at the same time I feel kind of queasy sending a pull request without having the tests finish.
5. On that note, I haven't written any tests. I did some manual testing, so I know it everything works. I don't know if that's enough for you guys.

Also, the last three commits are all just small bug fixes. The "merge" was just that I stupidly tried to amend my first bug fixing commit after pushing it to github.