You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@annotator.apache.org by ge...@apache.org on 2020/07/23 13:42:59 UTC

[incubator-annotator] 04/05: Support highlighting empty ranges

This is an automated email from the ASF dual-hosted git repository.

gerben pushed a commit to branch tweak-highlighter
in repository https://gitbox.apache.org/repos/asf/incubator-annotator.git

commit a8fe93e147ddd484cd972fdaa6d3f4085788e300
Author: Gerben <ge...@treora.com>
AuthorDate: Thu Jul 23 14:12:29 2020 +0200

    Support highlighting empty ranges
    
    Can be useful to mark a specific point in a text. And if ignoring
    collapsed ranges is desirable, the user can just check whether
    range.collapsed is true.
---
 packages/dom/src/highlight-range.ts | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/packages/dom/src/highlight-range.ts b/packages/dom/src/highlight-range.ts
index 043d739..90b3efa 100644
--- a/packages/dom/src/highlight-range.ts
+++ b/packages/dom/src/highlight-range.ts
@@ -55,9 +55,6 @@ export function highlightRange(
 
 // Return an array of the text nodes in the range. Split the start and end nodes if required.
 function textNodesInRange(range: Range): Text[] {
-  // If the range is empty, avoid creating and returning an empty text node.
-  if (range.collapsed) return [];
-
   // If the start or end node is a text node and only partly in the range, split it.
   if (
     isTextNode(range.startContainer) &&