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

feat: Allow selector traits to be conditionally filtered #8

Merged
merged 1 commit into from
Apr 5, 2024

Conversation

mike-plummer
Copy link

Enabling selector traits to be conditionally filtered so that they can be included/excluded based on user-supplied config. The idea is that creating selectors based off id could be configured to ignore certain patterns of auto-generated values:

unique(
  el,
  {
    selectorTypes: ['id'],
    filters: {
      'id': (type, key, value) => {
        return !isAutoGeneratedValue(value)
      }
    }
  }
)

This filtering piggybacks on existing behavior in the selector generation logic to effectively pretend various traits (or portions of traits) just don't exist, thus can't be used when building selectors and automatically falling back to the next-highest-precedence trait.

The initial intent here is to support UICoverage user-supplied config to address auto-generated values breaking element de-duping. This will be primarily around attribute-based selector filters, but for completeness I've added support for filtering all selector types. Aggregate-style traits (class and attributes) allow filtering by part so that individual attribute names/values and classes can be filtered.

In addition, I've done some minor cleanup of attribute logic (using updated element APIs rather than iterating using older-style APIs).

@mike-plummer mike-plummer merged commit 74c9036 into master Apr 5, 2024
3 checks passed
Copy link

github-actions bot commented Apr 5, 2024

🎉 This PR is included in version 1.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants