Where did the Text Selection API go?

时间秒杀一切 提交于 2020-02-24 17:31:46

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!