From bcd2de162aa68eb700d2a048a39da55e7e0a274c Mon Sep 17 00:00:00 2001 From: Rustam Sharshenov Date: Mon, 13 Apr 2020 21:32:09 +0100 Subject: [PATCH] Do not set role="form" by default Fixes warning of W3C validator: The "form" role is unnecessary for element "form". https://stackoverflow.com/questions/35397871/role-attribute-obsolete-in-form-or-nav-tags --- CHANGELOG.md | 2 +- lib/bootstrap_form/form_builder.rb | 1 - test/bootstrap_checkbox_test.rb | 10 ++--- test/bootstrap_fields_test.rb | 10 ++--- test/bootstrap_form_group_test.rb | 8 ++-- test/bootstrap_form_test.rb | 58 ++++++++++++++--------------- test/bootstrap_radio_button_test.rb | 8 ++-- test/bootstrap_selects_test.rb | 14 +++---- 8 files changed, 55 insertions(+), 56 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b06cff21..42782ed9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ ### Bugfixes -* Your contribution here! +* [#560](https://github.com/bootstrap-ruby/bootstrap_form/pull/560): Do not set role="form" by default - [@sharshenov](https://github.com/sharshenov). ## [4.4.0][] (2020-03-08) diff --git a/lib/bootstrap_form/form_builder.rb b/lib/bootstrap_form/form_builder.rb index 9b42d509e..21a1850b9 100644 --- a/lib/bootstrap_form/form_builder.rb +++ b/lib/bootstrap_form/form_builder.rb @@ -65,7 +65,6 @@ def initialize(object_name, object, template, options) def add_form_role_and_form_inline(options) options[:html] ||= {} - options[:html][:role] ||= "form" return unless options[:layout] == :inline diff --git a/test/bootstrap_checkbox_test.rb b/test/bootstrap_checkbox_test.rb index 8e22ce2c2..dbbc7cc23 100644 --- a/test/bootstrap_checkbox_test.rb +++ b/test/bootstrap_checkbox_test.rb @@ -123,7 +123,7 @@ class BootstrapCheckboxTest < ActionView::TestCase test "inline checkboxes from form layout" do expected = <<-HTML.strip_heredoc -
+ #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -581,7 +581,7 @@ class BootstrapCheckboxTest < ActionView::TestCase @user.errors.add(:misc, "a box must be checked") expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -610,7 +610,7 @@ class BootstrapCheckboxTest < ActionView::TestCase @user.errors.add(:misc, "error for test") collection = [Address.new(id: 1, street: "Foo"), Address.new(id: 2, street: "Bar")] expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -637,7 +637,7 @@ class BootstrapCheckboxTest < ActionView::TestCase test "check_box renders error when asked" do @user.errors.add(:terms, "You must accept the terms.") expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -658,7 +658,7 @@ class BootstrapCheckboxTest < ActionView::TestCase test "check_box with error is wrapped correctly with custom option set" do @user.errors.add(:terms, "You must accept the terms.") expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
diff --git a/test/bootstrap_fields_test.rb b/test/bootstrap_fields_test.rb index f7ec74d0c..1c8340102 100644 --- a/test/bootstrap_fields_test.rb +++ b/test/bootstrap_fields_test.rb @@ -99,7 +99,7 @@ class BootstrapFieldsTest < ActionView::TestCase test "file fields are wrapped correctly with error" do @user.errors.add(:misc, "error for test") expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -321,7 +321,7 @@ class BootstrapFieldsTest < ActionView::TestCase end expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -342,7 +342,7 @@ class BootstrapFieldsTest < ActionView::TestCase end expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -363,7 +363,7 @@ class BootstrapFieldsTest < ActionView::TestCase end expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -387,7 +387,7 @@ class BootstrapFieldsTest < ActionView::TestCase end expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
diff --git a/test/bootstrap_form_group_test.rb b/test/bootstrap_form_group_test.rb index 9bc072ea4..75ccfef5b 100644 --- a/test/bootstrap_form_group_test.rb +++ b/test/bootstrap_form_group_test.rb @@ -186,7 +186,7 @@ class BootstrapFormGroupTest < ActionView::TestCase assert @user.invalid? expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -432,7 +432,7 @@ class BootstrapFormGroupTest < ActionView::TestCase end expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -491,7 +491,7 @@ class BootstrapFormGroupTest < ActionView::TestCase end expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -595,7 +595,7 @@ class BootstrapFormGroupTest < ActionView::TestCase test "custom form group layout option" do expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
diff --git a/test/bootstrap_form_test.rb b/test/bootstrap_form_test.rb index 04c52522f..70ec6fc7d 100644 --- a/test/bootstrap_form_test.rb +++ b/test/bootstrap_form_test.rb @@ -7,7 +7,7 @@ class BootstrapFormTest < ActionView::TestCase test "default-style forms" do expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'} HTML @@ -16,7 +16,7 @@ class BootstrapFormTest < ActionView::TestCase test "default-style form fields layout horizontal" do expected = <<-HTML.strip_heredoc -
+ #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -68,7 +68,7 @@ class BootstrapFormTest < ActionView::TestCase test "default-style form fields layout inline" do expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -120,7 +120,7 @@ class BootstrapFormTest < ActionView::TestCase # generate a default ID for the form element. test "default-style forms bootstrap_form_with Rails 5.1+" do expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'} HTML @@ -130,7 +130,7 @@ class BootstrapFormTest < ActionView::TestCase test "inline-style forms" do expected = <<-HTML.strip_heredoc -
+ #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -175,7 +175,7 @@ class BootstrapFormTest < ActionView::TestCase test "horizontal-style forms" do expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -226,7 +226,7 @@ class BootstrapFormTest < ActionView::TestCase test "horizontal-style form fields layout default" do expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -272,7 +272,7 @@ class BootstrapFormTest < ActionView::TestCase test "horizontal-style form fields layout inline" do expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -318,7 +318,7 @@ class BootstrapFormTest < ActionView::TestCase test "existing styles aren't clobbered when specifying a form style" do expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -332,7 +332,7 @@ class BootstrapFormTest < ActionView::TestCase bootstrap_form_for(@user, layout: :horizontal, html: { class: "my-style" }) { |f| f.email_field :email } end - test "given role attribute should not be covered by default role attribute" do + test "given role attribute be applied" do expected = <<-HTML.strip_heredoc #{'' unless ::Rails::VERSION::STRING >= '6'} @@ -343,7 +343,7 @@ class BootstrapFormTest < ActionView::TestCase test "bootstrap_form_tag acts like a form tag" do expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -357,7 +357,7 @@ class BootstrapFormTest < ActionView::TestCase test "bootstrap_form_for does not clobber custom options" do expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -370,7 +370,7 @@ class BootstrapFormTest < ActionView::TestCase test "bootstrap_form_tag does not clobber custom options" do expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -390,7 +390,7 @@ class BootstrapFormTest < ActionView::TestCase name = "[misc]" end expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -407,7 +407,7 @@ class BootstrapFormTest < ActionView::TestCase assert @user.invalid? expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -423,7 +423,7 @@ class BootstrapFormTest < ActionView::TestCase assert @user.invalid? expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -443,7 +443,7 @@ class BootstrapFormTest < ActionView::TestCase assert @user.invalid? expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -501,7 +501,7 @@ class BootstrapFormTest < ActionView::TestCase end expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}

Please fix the following errors:

@@ -525,7 +525,7 @@ class BootstrapFormTest < ActionView::TestCase end expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}

Please fix the following errors:

@@ -544,7 +544,7 @@ class BootstrapFormTest < ActionView::TestCase end expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}

Please fix the following errors:

@@ -592,7 +592,7 @@ class BootstrapFormTest < ActionView::TestCase test "custom label width for horizontal forms" do expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -608,7 +608,7 @@ class BootstrapFormTest < ActionView::TestCase test "offset for form group without label respects label width for horizontal forms" do expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -624,7 +624,7 @@ class BootstrapFormTest < ActionView::TestCase test "offset for form group without label respects multiple label widths for horizontal forms" do expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -640,7 +640,7 @@ class BootstrapFormTest < ActionView::TestCase test "custom input width for horizontal forms" do expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -656,7 +656,7 @@ class BootstrapFormTest < ActionView::TestCase test "additional input col class" do expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -680,7 +680,7 @@ class BootstrapFormTest < ActionView::TestCase end expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -701,7 +701,7 @@ class BootstrapFormTest < ActionView::TestCase end expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -726,7 +726,7 @@ class BootstrapFormTest < ActionView::TestCase end expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -747,7 +747,7 @@ class BootstrapFormTest < ActionView::TestCase end expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
diff --git a/test/bootstrap_radio_button_test.rb b/test/bootstrap_radio_button_test.rb index 9f76172c2..3eea3789a 100644 --- a/test/bootstrap_radio_button_test.rb +++ b/test/bootstrap_radio_button_test.rb @@ -31,7 +31,7 @@ class BootstrapRadioButtonTest < ActionView::TestCase test "radio_button with error is wrapped correctly" do @user.errors.add(:misc, "error for test") expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -98,7 +98,7 @@ class BootstrapRadioButtonTest < ActionView::TestCase test "radio_button inline label is set correctly from form level" do expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -182,7 +182,7 @@ class BootstrapRadioButtonTest < ActionView::TestCase @user.errors.add(:misc, "error for test") collection = [Address.new(id: 1, street: "Foo"), Address.new(id: 2, street: "Bar")] expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -417,7 +417,7 @@ class BootstrapRadioButtonTest < ActionView::TestCase test "radio_button with error is wrapped correctly with custom option set" do @user.errors.add(:misc, "error for test") expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
diff --git a/test/bootstrap_selects_test.rb b/test/bootstrap_selects_test.rb index 7cae17e6f..bcba4feb5 100644 --- a/test/bootstrap_selects_test.rb +++ b/test/bootstrap_selects_test.rb @@ -37,7 +37,7 @@ def options_range(start: 1, stop: 31, selected: nil, months: false) test "time zone selects are wrapped correctly with error" do @user.errors.add(:misc, "error for test") expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -192,7 +192,7 @@ def options_range(start: 1, stop: 31, selected: nil, months: false) test "collection_selects are wrapped correctly with error" do @user.errors.add(:status, "error for test") expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -253,7 +253,7 @@ def options_range(start: 1, stop: 31, selected: nil, months: false) test "grouped_collection_selects are wrapped correctly with error" do @user.errors.add(:status, "error for test") expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -340,7 +340,7 @@ def options_range(start: 1, stop: 31, selected: nil, months: false) test "date selects inline when layout is horizontal" do Timecop.freeze(Time.utc(2012, 2, 3)) do expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -368,7 +368,7 @@ def options_range(start: 1, stop: 31, selected: nil, months: false) @user.errors.add(:misc, "error for test") Timecop.freeze(Time.utc(2012, 2, 3)) do expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -469,7 +469,7 @@ def options_range(start: 1, stop: 31, selected: nil, months: false) @user.errors.add(:misc, "error for test") Timecop.freeze(Time.utc(2012, 2, 3, 12, 0, 0)) do expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -577,7 +577,7 @@ def options_range(start: 1, stop: 31, selected: nil, months: false) @user.errors.add(:misc, "error for test") Timecop.freeze(Time.utc(2012, 2, 3, 12, 0, 0)) do expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}