Skip to content

Commit

Permalink
Revert "Convert values to strings on normalize_value"
Browse files Browse the repository at this point in the history
This reverts commit ef01ed3.
  • Loading branch information
josevalim committed Oct 9, 2023
1 parent eab0d81 commit 7bb7857
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
9 changes: 3 additions & 6 deletions lib/phoenix_html/form.ex
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,6 @@ defmodule Phoenix.HTML.Form do
won't be ignored on submission. This requires however
that the textarea is rendered with no spaces after its
content
All other values are HTML escaped.
"""
def normalize_value("datetime-local", %struct{} = value)
when struct in [NaiveDateTime, DateTime] do
Expand All @@ -250,10 +248,9 @@ defmodule Phoenix.HTML.Form do
html_escape(value) == {:safe, "true"}
end

def normalize_value(_type, nil), do: nil
def normalize_value(_type, true), do: true
def normalize_value(_type, false), do: false
def normalize_value(_type, value), do: html_escape(value)
def normalize_value(_type, value) do
value
end

@doc """
Returns options to be used inside a select.
Expand Down
3 changes: 1 addition & 2 deletions test/phoenix_html/form_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ defmodule Phoenix.HTML.FormTest do
end

test "for anything else" do
assert normalize_value("foo", nil) == nil
assert normalize_value("foo", "<other>") == {:safe, [[[] | "&lt;"], "other" | "&gt;"]}
assert normalize_value("foo", "<other>") == "<other>"
end
end

Expand Down

0 comments on commit 7bb7857

Please sign in to comment.