Closed Kuret closed 1 year ago
Please do send a PR!
Hi,
I'm not too familiar with this code. I see that these form_defaults
functions are also there for other elements, where there is no specific match on a [value]
.
Is there a specific reason this is only done this way for textarea's or can I just assume a default of [""]
?
After playing around with the codebase, I couldn't find any side effect of assuming a default of [""]
(Floki's default parsing already sets that when the node is empty anyways), so I made a PR for this.
Closing in favor of the PR!
Environment
Actual behavior
When using the
fast_html
engine configured for Floki, tests with (for example)render_change
fail when testing a form that includes a textarea with no inner value.For example, in our view we have a textarea, bound to a form with an empty changeset (so no initial value)
Our test contains:
Produces an error:
This happens because for the default
mochiweb
parser Floki uses, a textarea always gets (incorrectly) parsed with an empty string value:In contrast,
fast_html
does not return an empty value (correctly so imo):This in turn causes a
FunctionClauseError
in LiveViewTest's ClientProxy module, because this textarea has no value:Expected behavior
render_change
does not fail on empty textareas regardless of which HTML Engine is used.We use
fast_html
for (for example) parsing some returned html from external API calls and markdown-y parsing/previews so we need the tests to be able to use the same engine.