Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix HTMLFormatter for textarea #2840

Merged
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion lib/phoenix_live_view/html_formatter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ defmodule Phoenix.LiveView.HTMLFormatter do
source
) do
{mode, block} =
if (tag_name in ["pre", "textarea"] or contains_special_attrs?(attrs)) and buffer != [] do
if tag_name in ["pre", "textarea"] or contains_special_attrs?(attrs) do
content = content_from_source(source, open_meta.inner_location, close_meta.inner_location)
{:preserve, [{:text, content, %{newlines: 0}}]}
else
Expand Down
9 changes: 6 additions & 3 deletions test/phoenix_live_view/html_formatter_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1666,9 +1666,12 @@ if Version.match?(System.version(), ">= 1.13.0") do
<textarea />
""")

assert_formatter_doesnt_change("""
<textarea></textarea>
""")
assert_formatter_doesnt_change(
"""
<textarea></textarea>
""",
line_length: 5
)
end

test "keeps right format for inline elements within block elements" do
Expand Down