diff --git a/index.html b/index.html index 0156d4b..c83cb48 100644 --- a/index.html +++ b/index.html @@ -144,7 +144,7 @@

If the selection's range is not null and is [=range/collapsed=], then the caret position must be at that range's boundary point. When the selection is not - empty, this specification does not define the caret position; user + [=range/collapsed=], this specification does not define the caret position; user agents should follow platform conventions in deciding whether the caret is at the start of the selection, the end of the selection, or somewhere else. @@ -175,6 +175,11 @@

focus is the [=range/end=]. Otherwise, its focus is the [=range/start=] and its anchor is the [=range/end=].

+

+ anchor and focus of selection need not to be + in the [=document tree=]. It could be in a [=shadow tree=] of + the same [=document=]. +

@@ -199,6 +204,7 @@

undefined removeRange(Range range); undefined removeAllRanges(); undefined empty(); + StaticRange getComposedRange(ShadowRoot... shadowRoots); undefined collapse(Node? node, optional unsigned long offset = 0); undefined setPosition(Node? node, optional unsigned long offset = 0); undefined collapseToStart(); @@ -219,7 +225,8 @@

The attribute must return the anchor [=boundary point/node=] - of [=this=], or `null` if the anchor is null. + of [=this=], or `null` if the anchor is null or anchor + is not in the [=document tree=].

@@ -229,7 +236,7 @@

The attribute must return the anchor [=boundary point/offset=] of [=this=], or 0 if the anchor - is null. + is null or anchor is not in the [=document tree=].

@@ -238,7 +245,8 @@

The attribute must return the focus [=boundary point/node=] - of [=this=], or `null` if the focus is null. + of [=this=], or `null` if the focus is null or focus + is not in the [=document tree=].

@@ -248,7 +256,7 @@

The attribute must return the focus [=boundary point/offset=] of [=this=], or 0 if the focus - is null. + is null or focus is not in the [=document tree=].

@@ -267,7 +275,8 @@

The attribute must return 0 if [=this=] is - empty, and must return 1 otherwise. + empty or either focus or anchor is not in the + [=document tree=], and must return 1 otherwise.

@@ -275,7 +284,8 @@

- The attribute must return `"None"` if [=this=] is empty, + The attribute must return `"None"` if [=this=] is empty or + either focus or anchor is not in the [=document tree=], `"Caret"` if [=this=]'s range is [=range/collapsed=], and `"Range"` otherwise.

@@ -287,7 +297,8 @@

The method must throw an {{IndexSizeError}} exception if index is not 0, or if [=this=] is - empty. Otherwise, it must return a reference to (not a copy + empty or either focus or anchor is not in the + [=document tree=]. Otherwise, it must return a reference to (not a copy of) [=this=]'s range.

@@ -361,7 +372,7 @@

- empty + empty() method

@@ -369,6 +380,37 @@

removeAllRanges().

+
+ getComposedRange() method +
+
+
    +
  1. If [=this=] is empty, return a new {{StaticRange}} whose [=range/start node=] + and [=range/end node=] are null and whose [=range/start offset=] and [=range/end offset=] are 0.
  2. +
  3. Let startNode be [=range/start node=] of the [=range=] associated with [=this=], + and let startOffset be [=range/start offset=] of the [=range=].
  4. +
  5. While startNode is a [=node=], startNode's [=tree/root=] is a [=shadow root=], + and startNode is not a [=shadow-including inclusive ancestor=] of any of shadowRoots, + repeat these steps: +
      +
    1. Set startOffset to [=tree/index=] of startNode's [=tree/root=]'s [=host=].
    2. +
    3. Set startNode to startNode's [=tree/root=]'s [=host=]'s [=tree/parent=].
    4. +
    +
  6. +
  7. Let endNode be [=range/end node=] of the [=range=] associated with [=this=], + and let endOffset be [=range/end offset=] of the [=range=].
  8. +
  9. While endNode is a [=node=], endNode's [=tree/root=] is a [=shadow root=], + and endNode is not a [=shadow-including inclusive ancestor=] of any of shadowRoots, + repeat these steps: +
      +
    1. Set endOffset to [=tree/index=] of endNode's [=tree/root=]'s [=host=] plus 1.
    2. +
    3. Set endNode to endNode's [=tree/root=]'s [=host=]'s [=tree/parent=].
    4. +
    +
  10. +
  11. Return a new {{StaticRange}} whose [=range/start node=] is startNode, [=range/start offset=] + is startOffset, [=range/end node=] is endNode, and [=range/end offset=] is endOffset.
  12. +
+
collapse() method
@@ -634,8 +676,8 @@

The method must invoke {{Range/deleteContents()}} on [=this=]'s - range if [=this=] is not empty. Otherwise the method - must do nothing. + range if [=this=] is not empty and both focus and anchor + are in the [=document tree=]. Otherwise the method must do nothing.

This is the one method that actually mutates the range instead of @@ -820,13 +862,35 @@

+
+

+ Responding to DOM Mutations +

+

+ When the user agent is to [=replace data=] or [=CharacterData/substring data=] on {{CharacterData}}, + the user agent must update the range associated with selection of the [=Node/node document=] + of the {{CharacterData}} as if it's a live range. +

+

+ When the user agent is to split a {{Text}} [=node=], the user agent must update the range associated with + selection of the [=Node/node document=] of the {{Text}} as if it's a live range. +

+

+ When the user agent is to run steps for normalize() method, the user agent must update + the range associated with selection of the [=Node/node document=] of [=this=] as if it's a live range. +

+

+ When the user agent is to [=remove=] or [=insert=] a [=node=], the user agent must update + the range associated with selection of the [=Node/node document=] of the [=node=] as if it's a live range. +

+

User Interactions

The user agent should allow the user to change the selection - associated with the active document. If the user makes any + associated with the [=navigable/active document=]. If the user makes any modification to a selection, the user agent must create a new range with suitable [=range/start=] and [=range/end=] of the range and associate the selection with this new