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

Confusing array filter logic #15

Closed
EvitanRelta opened this issue Dec 16, 2022 · 0 comments
Closed

Confusing array filter logic #15

EvitanRelta opened this issue Dec 16, 2022 · 0 comments
Assignees
Labels
improve Improvements on existing feature

Comments

@EvitanRelta
Copy link
Owner

EvitanRelta commented Dec 16, 2022

Currently, if the a rule's filter is an array of tag-names (ie. TagName[]), the elements are OR against each other.
eg. filter: ['b', 'strong'] is logically "element has the tag-name 'b' OR 'strong'"

But if the array contains an element of type FilterPredicate, the elements are suddenly AND against each other.
eg. filter: ['b', isStrong] is logically "element has the tag-name 'b' AND isStrong"

Also, for convenience, the rules' filters are allowed to be a single (ie. not an array) TagName or FilterPredicate type.
eg. filter: 'b' or filter: isStrong, which slightly complicates the typings and evaluation of the filters.


A better evaluation logic would be:

  • disallow just filter: TagName | FilterPredicate types (ie. only allow arrays)
  • allow nested arrays where:
    • the outer array is OR logically
    • the inner array is AND logically
      (ie. [A, [B, C], D] is logically "A or (B and C) or D")
@EvitanRelta EvitanRelta added the improve Improvements on existing feature label Dec 16, 2022
@EvitanRelta EvitanRelta self-assigned this Dec 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improve Improvements on existing feature
Projects
None yet
Development

No branches or pull requests

1 participant