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

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

commit 6bab278edede89032e958df3477aeaec9f1ef328
Author: Gerben <[email protected]>
AuthorDate: Fri Nov 20 12:03:45 2020 +0100

    This is what do–while was invented for :)
---
 packages/dom/src/text-quote/match.ts | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/packages/dom/src/text-quote/match.ts 
b/packages/dom/src/text-quote/match.ts
index dea1f68..dd69227 100644
--- a/packages/dom/src/text-quote/match.ts
+++ b/packages/dom/src/text-quote/match.ts
@@ -66,9 +66,9 @@ export function abstractTextQuoteSelectorMatcher(
     }
     let partialMatches: PartialMatch[] = [];
 
-    let chunk: TChunk | null;
     let isFirstChunk = true;
-    while (chunk = textChunks.currentChunk) {
+    do {
+      const chunk = textChunks.currentChunk;
       const chunkValue = chunk.data;
 
       // 1. Continue checking any partial matches from the previous chunk(s).
@@ -158,10 +158,7 @@ export function abstractTextQuoteSelectorMatcher(
         partialMatches.push(partialMatch);
       }
 
-      if (textChunks.nextChunk() === null)
-        break;
-
       isFirstChunk = false;
-    }
+    } while (textChunks.nextChunk() !== null);
   };
 }

Reply via email to