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

Allow custom filter functions as blacklist/whitelist #212

Closed
fregante opened this issue Feb 19, 2022 · 1 comment
Closed

Allow custom filter functions as blacklist/whitelist #212

fregante opened this issue Feb 19, 2022 · 1 comment
Assignees

Comments

@fregante
Copy link
Contributor

The selector filters only accept regexes and strings:

whitelist: [] as Array<CssSelectorMatch>,
blacklist: [] as Array<CssSelectorMatch>,

export type CssSelectorMatch = RegExp | string

Would you accept a PR to add support for functions? Example:

getCssSelector(
  targetElement,
  { blacklist:
      [
        // ID selector
        '#forbiddenId',

        // predicate function
        selector => !isCoolSelector(selector)
      ]
  }
)
@fczbkk
Copy link
Owner

fczbkk commented Feb 21, 2022

Hey @fregante, thanks for the suggestion and for the pull request. In the end, I did not use your pull request, because I wanted to implement it in a slightly different way and I also wanted to add more tests and update documentation.

I have generated v3.6.0, which includes this feature. See:
https://www.npmjs.com/package/css-selector-generator/v/3.6.0#blacklist

@fczbkk fczbkk closed this as completed Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants