philss / floki

Floki is a simple HTML parser that enables search for nodes using CSS selectors.
https://hex.pm/packages/floki
MIT License
2.07k stars 156 forks source link

Floki.text doesn't find text in array of simple text nodes #91

Closed boydm closed 7 years ago

boydm commented 7 years ago

In version 0.9, Floki.text(["hello world"]) would return "hello world"

In version 0.13, Floki.text(["hello world"]) returns "" note that Floki.text([{"div", [], ["hello world"]}]) returns "hello world"

This is an issue when I've already drilled down into the div and I just want to get the text of its children. A bug or is there an updated syntax?

philss commented 7 years ago

@boydm thank you for open the issue. I will try to take a look tomorrow.

boydm commented 7 years ago

fyi Floki.FlatText.get(["hello world"]) does return "hello world"

philss commented 7 years ago

@boydm this is definitely a bug introduced in version 0.13. The problem is that now Floki builds a representation of HTML tree using a map with references to its children nodes. For the case of a HTML tree that contains with only text as root nodes Floki is ignoring those nodes.

I will try to fix this soon. Thanks again!

philss commented 7 years ago

@boydm this bug is fixed in version 0.13.2. Please update to that version. Thanks!

boydm commented 7 years ago

Thank you very much!