/* getSelection code This document is a testbed for some code to work with the frighteningly inconvenient getSelection() API that browsers unfortunately seem to have standardized.

It seems that triple-clicking a paragraph gives you a selection that extends into the following paragraph... maybe the problem is that endContainer then is that ELEMENT_NODE instead of a TEXT_NODE? So I should stop recursing as soon as I see the endContainer? But that sometimes gets me no text...

W3C spec.
12
34

MDN says of the Range object:

Properties

collapsed
Returns a boolean indicating whether the range's start and end points are at the same position.
commonAncestorContainer
Returns the deepest Node  that contains the startContainer and endContainer Nodes.
endContainer
Returns the Node  within which the Range ends.
endOffset
Returns a number representing where in the endContainer the Range ends.
startContainer
Returns the Node  within which the Range starts.
startOffset
Returns a number representing where in the startContainer the Range starts.