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 f37e397174028751fc002f7a26311604bcef95d9 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); }; }
