问题
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?
回答1:
It moved to WHATWG's DOM Range spec. The Range portion of that document has very recently (within the last week or so) been migrated to W3C's DOM4 spec.
This leaves the WHATWG Range spec in the position of being rather misleadlingly named. I'm not sure whether there are plans to move the Selection stuff again but I wouldn't bet against it.
Update February 2013
The Selection portion of the spec is currently found in the HTML Editing APIs spec.
来源:https://stackoverflow.com/questions/7471515/where-did-the-text-selection-api-go