Skip to content

Commit a12af5e

Browse files
authored
Merge pull request #302 from shypple/fix-invalid-html
Fix invalid html generation
2 parents 60ddc29 + d944ba7 commit a12af5e

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

lib/activeadmin_addons/active_admin_config.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ class ActiveAdmin::Views::Pages::Base
33

44
def build(*args)
55
original_build(args)
6+
body = get_elements_by_tag_name("body").first
67
body.set_attribute "data-default-select", ActiveadminAddons.default_select
78
end
89
end

lib/activeadmin_addons/support/input_base.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ def to_html
1616
end
1717

1818
def input_html_options
19-
super.merge(control_attributes)
19+
# maxwidth and size are added by Formtastic::Inputs::StringInput
20+
# but according to the HTML standard these are not valid attributes
21+
# on the inputs provided by this module
22+
super.except(:maxlength, :size).merge(control_attributes)
2023
end
2124

2225
def parts_to_html

spec/features/inputs/select2_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,21 @@
7676
expect(page).to have_selector("select.select2")
7777
end
7878
end
79+
80+
context "when building ActiveAdmin html" do
81+
describe "the <body> element" do
82+
it "is present in the document only once" do
83+
visit admin_invoices_path
84+
85+
expect(page.all('body').size).to eq 1
86+
end
87+
88+
it "contains the data-default-select attribute" do
89+
visit admin_invoices_path
90+
91+
body = find("body")
92+
expect(body['data-default-select']).to eq ActiveadminAddons.default_select
93+
end
94+
end
95+
end
7996
end

0 commit comments

Comments
 (0)