mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Simplify html attributes generation for options_for_select
Further simplify the option_html_attributes method after the changes
introduced in dacbcbe557
to not escape the
html options here (since they're going to be escaped down the chain in
content tag).
This commit is contained in:
parent
ce06b8a56c
commit
e8e8617c39
2 changed files with 11 additions and 8 deletions
|
@ -708,9 +708,11 @@ module ActionView
|
|||
|
||||
private
|
||||
def option_html_attributes(element)
|
||||
return {} unless Array === element
|
||||
|
||||
Hash[element.select { |e| Hash === e }.reduce({}, :merge).map { |k, v| [k, v] }]
|
||||
if Array === element
|
||||
element.select { |e| Hash === e }.reduce({}, :merge)
|
||||
else
|
||||
{}
|
||||
end
|
||||
end
|
||||
|
||||
def option_text_and_value(option)
|
||||
|
|
|
@ -1164,11 +1164,12 @@ class FormOptionsHelperTest < ActionView::TestCase
|
|||
)
|
||||
end
|
||||
|
||||
def test_option_html_attributes_from_without_hash
|
||||
assert_equal(
|
||||
{},
|
||||
option_html_attributes([ 'foo', 'bar' ])
|
||||
)
|
||||
def test_option_html_attributes_with_no_array_element
|
||||
assert_equal({}, option_html_attributes('foo'))
|
||||
end
|
||||
|
||||
def test_option_html_attributes_without_hash
|
||||
assert_equal({}, option_html_attributes([ 'foo', 'bar' ]))
|
||||
end
|
||||
|
||||
def test_option_html_attributes_with_single_element_hash
|
||||
|
|
Loading…
Reference in a new issue