-
-
Notifications
You must be signed in to change notification settings - Fork 155
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
Cannot search with multiple selectors #18
Comments
5 tasks
philss
added a commit
that referenced
this issue
Sep 17, 2015
This is a huge refactor in the `Floki.find/2` function that enables more complex searches using a mix of selectors. You can mix selectors like you would normally do in other tools like jQuery or to apply rules using CSS selectors. Examples of queries now supported: - "a.foo" - ".foo.bar" - ".baz[data='something']" - "[title][href$='.html']" - "a b.foo c" To archive this, it was necessary to write a tokenizer and a parser for the inputted selector. It's quite easy to understand after read this article by Andrea Leopardi (@whatyouhide) about tokenizing and parsing in Elixir: http://andrealeopardi.com/posts/tokenizing-and-parsing-in-elixir-using-leex-and-yecc/ The tokenizer partially covers the specs of CSS3 selectors, that you can find at http://www.w3.org/TR/css3-selectors/ Knowning issues: - There is no support for pseudo-selectors; - The only combinator supported is descendant combinator; - If there is a group of selectors in the same query, and two selectors matches the same node, this node will appear twice in the resultant list. Closes #18 and #20.
@licyeus Please check the new released version "0.4.0". It provides this selector and much more. |
Thanks much 🎆; looking at diffs looks to cover my use cases. However, I'm running into errors compiling 0.4. Created #25 for that. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With
@html
markup fromtest/floki_test.exs
:I am trying to search for an element with multiple classes (on the same element) with the selector
.js-cool.js-elixir
but Floki is not finding them. However, if I add a space between the classes, as if the second was a descendent of the first,.js-cool .js-elixir
, it does return what I'm looking for but should not (asjs-elixir
is not descendent ofjs-cool
).Test demonstrating the error:
The text was updated successfully, but these errors were encountered: