philss / floki

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

Find fails on hidden fields #279

Closed ChipCoons closed 4 years ago

ChipCoons commented 4 years ago

Description

When using Floki.find(fragment, "#name) where name is the name of an attribute of type="hidden", an empty list is returned.

To Reproduce

Steps to reproduce the behavior:

Expected behavior

[ {"input", [ {"type", "hidden"}, {"value", "2736e8e5-7c83-49c1-922e-e00a8fa967e5"}, {"name", "_csrf"} ], [] } ]

If I use the find function on any non-hidden, named field, I get the expected results.

philss commented 4 years ago

@ChipCoons thank you for open the issue. I believe the problem is that you are using a ID selector instead of a attribute selector targeting the name="_csrf".

Please try this:

Floki.find(form_body, "input[name=_csrf]")

I'm closing the issue.

ChipCoons commented 4 years ago

That worked. Thanks. Thanks for making a great library as well.

-Chip

On Jun 12, 2020, at 4:13 PM, Philip Sampaio notifications@github.com wrote:

input[name=_csrf]