Bad results from Scanner.scan() for expressions like div, div div
Closed this issue · 6 comments
lukaseder commented
When I run this code:
Scanner scanner = new Scanner("div, div div");
List<List<Selector>> selectors = scanner.scan();
I get a list with 3 elements:
System.out.println(selectors.size());
System.out.println(selectors.get(0).size());
System.out.println(selectors.get(1).size());
System.out.println(selectors.get(2).size());
prints:
3
1
2
2
It looks like the last "div div" is duplicated. This may lead to inefficient matching, when executing the selection.
chrsan commented
Yep, something wrong there. If you have a clue as of now please feel free to send me a pull request.
lukaseder commented
I haven't analysed it just yet. I'll do later on...
So far I only know that it doesn't produce "wrong" output. selectors.get(1) and .get(2) seem identical, so they match the same nodes...
chrsan commented
I'll have a look at it when I have time to do so. It's bad to have to do the checks twice and even worse if it's a heavy expression so to speak.
chrsan commented
Fixed the big and added a test case for it.
lukaseder commented
Awesome! Works like a charm!
chrsan commented
Great!