-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TextQuoteSelector selector yielding an infinite number of matches #112
Comments
Can reproduce. The issue is that if the DOM is changed (by I would like our text matching to be resistant to DOM changes that do not modify the text content. I am not sure how easy or hard this may be to achieve. If we cannot fix this, it seems unhelpful to return an (async) iterable, and we’d better just return an array with the matches. For now, best is to avoid changing the DOM while running the matcher, and first collect the matches in an array. For example, we do this in the demo:
I see now that I gave the simpler but broken example in the getting started page. I will add update and a note! |
For now, I just added warnings to the documentation. Longer term, I’d really like to fix this, but it is not trivial to deal with search in a changing DOM. However, while robustness to arbitrary DOM changes may be hard, it gets easier if we limit ourselves to limited changes. In any case, it seems fair to limit our effort to DOM changes that keep the scope’s
Besides these kinds of changes, we could distinguish between changes on the nodes where the search is currently looking, changes before it, and changes ahead of it. Perhaps changes before and after it need not be a problem either, but we’d probably more often deal with changes at the nodes that are currently searched in (for highlighting and such). I would probably start with changing the approach of the abstract text quote matcher implementation. Currently, it manually walks through chunks, but I think it could be simpler by using a TextSeeker to do this. Then, perhaps we can create robustness to split nodes/chunks in there, by e.g. always checking if |
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:The text was updated successfully, but these errors were encountered: