Skip to content

Add filter feature on Selector functions and WrapperArray #334

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

Closed
wants to merge 2 commits into from

Conversation

Toilal
Copy link
Contributor

@Toilal Toilal commented Jan 8, 2018

This is an alternative to #328 to allow user to filter elements from WrapperArray.

@eddyerburgh eddyerburgh mentioned this pull request Jan 8, 2018
@eddyerburgh
Copy link
Member

Thanks for the PR.

I'm not sure we should add this feature. We talked about adding array methods a few months ago and decided against it as it would make the API to large. Perhaps we could make an exception for filter, but my concern would be that users would expect other array methods to be implemented.

@eddyerburgh
Copy link
Member

I'm also not sure about adding a predicate to methods that take a selector. We should start a feature request issue and get some feedback.

@Toilal
Copy link
Contributor Author

Toilal commented Jan 8, 2018

I need either this feature or #337, or I just can't use vue-test-utils for my component.

@eddyerburgh
Copy link
Member

You can use the suggestion 38elements gave:

wrapperArr = findAll('div')
wrapperArr.wrappers = wrapperArr.wrappers.filter(w => w.element.style.visibility === 'hidden')

@Toilal
Copy link
Contributor Author

Toilal commented Jan 8, 2018

On TypeScript, wrappers is marked as readonly so it won't compile. And I think length property will not be updated too.

@eddyerburgh
Copy link
Member

Ah, well we could potentially update the length property. I understand your use case, and we'll find a solution, but we need to discuss it first.

Copy link
Member

@eddyerburgh eddyerburgh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll add the filter method, but we're not going to add a predicate to selector methods for now. Can you remove the predicate from this PR, or create a new PR that adds the filter method?

@eddyerburgh
Copy link
Member

Thanks for the PR.

I've added the filter method in another PR, so we can close the issue.

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.

2 participants