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/09/10 20:03:54 UTC

[incubator-annotator] 02/04: Fix describeTextQuote’s clipping range to scope

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

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

commit 934746adb09c29c421aa3131b80ef6c2042d8715
Author: Gerben <ge...@treora.com>
AuthorDate: Tue Sep 8 19:34:44 2020 +0200

    Fix describeTextQuote’s clipping range to scope
---
 packages/dom/src/text-quote/describe.ts | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/packages/dom/src/text-quote/describe.ts b/packages/dom/src/text-quote/describe.ts
index 7db2bc3..dca21c8 100644
--- a/packages/dom/src/text-quote/describe.ts
+++ b/packages/dom/src/text-quote/describe.ts
@@ -36,9 +36,9 @@ export async function describeTextQuote(
   range = range.cloneRange();
 
   // Take the part of the range that falls within the scope.
-  if (!scope.isPointInRange(range.startContainer, range.startOffset))
+  if (range.compareBoundaryPoints(Range.START_TO_START, scope) === -1)
     range.setStart(scope.startContainer, scope.startOffset);
-  if (!scope.isPointInRange(range.endContainer, range.endOffset))
+  if (range.compareBoundaryPoints(Range.END_TO_END, scope) === 1)
     range.setEnd(scope.endContainer, scope.endOffset);
 
   return {