Two years ago the HTML5 standard dropped the chapter "Text Selection API" which contained a specification of the Selection
interface:
[Stringifies] interface Selection {
readonly attribute Node anchorNode;
readonly attribute long anchorOffset;
readonly attribute Node focusNode;
readonly attribute long focusOffset;
readonly attribute boolean isCollapsed;
void collapse(in Node parentNode, in long offset);
void collapseToStart();
void collapseToEnd();
void selectAllChildren(in Node parentNode);
void deleteFromDocument();
readonly attribute long rangeCount;
Range getRangeAt(in long index);
void addRange(in Range range);
void removeRange(in Range range);
void removeAllRanges();
};
See here: http://www.w3.org/TR/2009/WD-html5-20090423/editing.html#selection
I remember encountering this interface in another standard, but I forgot which one. Could anyone please refresh my memory?