Fix handling of 'size' attribute on numeric inputs
Validators complain that SimpleForm's numeric elements have a `size` attribute. According to the [spec][1], `input` elements with a `type` of `number` must not specify a `size`. This change removes the `size` option, and updates an existing unit test to guard against regressions. Users may still provide a `size` option manually, though it may produce invalid markup in certain situations. [1]: http://www.whatwg.org/specs/web-apps/current-work/multipage/number-state.html#number-state
This commit is contained in:
parent
5d4021f6b5
commit
0332313300
|
@ -3,7 +3,7 @@ module SimpleForm
|
|||
class NumericInput < Base
|
||||
def input
|
||||
input_html_options[:type] ||= "number" if SimpleForm.html5
|
||||
input_html_options[:size] ||= SimpleForm.default_input_size
|
||||
input_html_options[:size] ||= nil
|
||||
input_html_options[:step] ||= integer? ? 1 : "any" if SimpleForm.html5
|
||||
infer_attributes_from_validations! if SimpleForm.html5
|
||||
@builder.text_field(attribute_name, input_html_options)
|
||||
|
|
|
@ -141,9 +141,9 @@ class InputTest < ActionView::TestCase
|
|||
assert_select "input#user_password.password[type=password][name='user[password]']"
|
||||
end
|
||||
|
||||
test 'input should use default text size for decimal attributes' do
|
||||
test 'input should not use size attribute for decimal attributes' do
|
||||
with_input_for @user, :credit_limit, :decimal
|
||||
assert_select 'input.decimal[size=50]'
|
||||
assert_no_select 'input.decimal[size]'
|
||||
end
|
||||
|
||||
test 'input should get maxlength from column definition for string attributes' do
|
||||
|
|
Loading…
Reference in New Issue