ziodave opened a new issue #112:
URL: https://github.com/apache/incubator-annotator/issues/112


   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"
     }
   }));
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to