Add result count
lukasoppermann opened this issue ยท 9 comments
While one can easily build an extension to count the results, I think it would be sensible if holmes would keep track of how many results are visible, hidden and how many items exist overall.
Yeah, good idea, this could be added as a function.
Awesome, I guess since, you need to grab all the items in any case it will not result in a performance penalty.
In holmes there's no counting, but if it's in a separate function it's no big deal.
But you have the items available, correct?
I mean you need to do some kind of matching, so you will have a list of over all items and a list of not-matching items (at least) so you can apply the hidden
class.
This means:
- count items = items.length
- hidden = items.notMatching.length
- results = items.length - items.notMatching.length
๐
Yep, that's what I meant by no big deal
:)
Now that I'm trying to implement it, I notice that there's never a querySelectorAll
to get the hidden elements. This is because it is possible to add a .hidden
even when there already was one, without checking it previously (with classList
).
I'm going to implement this function, but it'll probably have a slight performance hit if you do this on every input character.
True, but you are looking over all elements and checking if they are visible. So you can just increment a counter in the loop and get the other number by substraction.
smooth addition
You can use h.count()
in v1.11.2