Skip to content

Cannot search with multiple selectors #18

@sllvn

Description

@sllvn

With @html markup from test/floki_test.exs:

<html>
<head>
<title>Test</title>
</head>
<body>
  <div class="content">
    <a href="http://google.com" class="js-google js-cool">Google</a>
    <a href="http://elixir-lang.org" class="js-elixir js-cool">Elixir lang</a>
    <a href="http://java.com" class="js-java">Java</a>
  </div>
</body>
</html>

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 (as js-elixir is not descendent of js-cool).

Test demonstrating the error:

test "find elements with given multiple classes" do
  class_selector = ".js-cool.js-elixir"

  assert Floki.find(@html, class_selector) == [
    {"a", [
        {"href", "http://elixir-lang.org"},
        {"class", "js-elixir js-cool"}],
      ["Elixir lang"]}
  ]
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions