Strip extra spaces from class html attribute for labels
This commit is contained in:
parent
dbf11d94ac
commit
e2938a4c56
|
@ -38,7 +38,7 @@ module SimpleForm
|
|||
end
|
||||
|
||||
def label_html_options
|
||||
label_options = html_options_for(:label, [input_type, required_class, SimpleForm.label_class])
|
||||
label_options = html_options_for(:label, [input_type, required_class, SimpleForm.label_class].compact)
|
||||
label_options[:for] = options[:input_html][:id] if options.key?(:input_html) && options[:input_html].key?(:id)
|
||||
label_options
|
||||
end
|
||||
|
|
|
@ -296,4 +296,13 @@ class IsolatedLabelTest < ActionView::TestCase
|
|||
assert_select 'label.my_custom_class'
|
||||
end
|
||||
end
|
||||
|
||||
test 'label strips extra classes even when label_class is nil' do
|
||||
swap SimpleForm, :label_class => nil do
|
||||
with_label_for @user, :name, :string
|
||||
assert_select "label[class='string required']"
|
||||
assert_no_select "label[class='string required ']"
|
||||
assert_no_select "label[class=' string required']"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue