Open
Description
Hello,
Can you help me out, I tried to understand what's going on here: I created the following, which indeed works, i.e. the text is highlighted in DOM.
However it enters an infinite loop in for await (const match of matches)
and I couldn't understand the cause:
async function highlightMatcher(matcher) {
const matches = matcher(document.body);
for await (const match of matches) {
highlightRange(match); // <----- this is called an infinite number of times
}
}
const createMatcher = makeRefinable((selector) => {
const innerCreateMatcher = {
TextQuoteSelector: createTextQuoteSelectorMatcher,
TextPositionSelector: createTextPositionSelectorMatcher,
CssSelector: createCssSelectorMatcher,
RangeSelector: makeCreateRangeSelectorMatcher(createMatcher)
}[selector.type];
if (!innerCreateMatcher) {
throw new Error(`Unsupported selector type: ${selector.type}`);
}
return innerCreateMatcher(selector);
});
highlightMatcher(createMatcher({
value: "#my-div",
type: "CssSelector",
refinedBy: {
type: "TextQuoteSelector",
exact: "My Text"
}
}));