Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions lib/floki/finder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ defmodule Floki.Finder do
end

defp get_selector_nodes(%Selector.Combinator{match_type: :child}, html_node, _tree) do
Enum.reverse(html_node.children_nodes_ids)
html_node.children_nodes_ids
end

defp get_selector_nodes(%Selector.Combinator{match_type: :adjacent_sibling}, html_node, tree) do
Expand Down Expand Up @@ -373,7 +373,6 @@ defmodule Floki.Finder do
case get_node(node_id, tree) do
%{children_nodes_ids: children} when children != [] ->
do_get_descendant_ids(children, tree, [])
|> Enum.reverse()

_ ->
[]
Expand All @@ -383,16 +382,17 @@ defmodule Floki.Finder do
defp do_get_descendant_ids([], _tree, acc), do: acc

defp do_get_descendant_ids([node_id | rest], tree, acc) do
acc = do_get_descendant_ids(rest, tree, acc)
acc = [node_id | acc]
acc =
case get_node(node_id, tree) do
%{children_nodes_ids: children} when children != [] ->
do_get_descendant_ids(children, tree, acc)

case get_node(node_id, tree) do
%{children_nodes_ids: children} when children != [] ->
do_get_descendant_ids(children, tree, acc)
_ ->
acc
end

_ ->
acc
end
acc = [node_id | acc]
do_get_descendant_ids(rest, tree, acc)
end

@spec map(Floki.html_tree() | Floki.html_node(), function()) ::
Expand Down
Loading