开发者

Where did the Text Selection API go?

开发者 https://www.devze.com 2023-04-05 16:43 出处:网络
Two years ago the HTML5 standard dropped the chapter \"Text Selection API\" which contained a specification of the Selection interface:

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 o开发者_如何学JAVAffset);
  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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消