Skip to content
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

Add convenience matcher functions to dom package #138

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Treora
Copy link
Contributor

@Treora Treora commented Nov 23, 2022

We have discussed similar APIs before, to make the common use cases easier.

  • createAnySelectorMatcher mimics the signature of existing matcher creators, but works on any selector type we support. For tools that try to maximise interoperability, matching a selector of any supported type should be easy; checking the type and using the right matcher is a task we can do for the user.

  • matchSelector wraps the this to make the common use case easy, hiding the generator and returning an array instead. Until they get advanced needs, a user should not have to care about async generators and curried functions to anchor a selector. Especially so as our highlighter messes up the matcher when used before the latter is finished (see issue TextQuoteSelector selector yielding an infinite number of matches #112).

Note this code depends on (and already includes the commits of) #136 and #137.

When trying to run yarn start, I get an error about missing imports, so probably I messed something up still..

Types & utility functions for annotations as a whole.

With code imported from <https://code.treora.com/gerben/web-annotation-utils>.
- createAnySelectorMatcher mimics the signature of existing matcher creators.
- matchSelector makes the common use case easy.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant