in packages/dom/src/text-quote/match.ts [71:90]
export function createTextQuoteSelectorMatcher(
selector: TextQuoteSelector,
): Matcher<Node | Range, Range> {
const abstractMatcher = abstractTextQuoteSelectorMatcher(selector);
return async function* matchAll(scope) {
let textChunks;
try {
textChunks = new TextNodeChunker(scope);
} catch (err) {
// An empty range contains no matches.
if (err instanceof EmptyScopeError) return;
else throw err;
}
for await (const abstractMatch of abstractMatcher(textChunks)) {
yield textChunks.chunkRangeToRange(abstractMatch);
}
};
}