Permalink
Browse files

tabindex should not be passed down to label_html_options (boolean inp…

…ut) fixes #859
  • Loading branch information...
1 parent e764875 commit 182b95411c28c0ee824456591a69dd1452bcc2d2 @justinfrench committed Jun 15, 2012
Showing with 12 additions and 1 deletion.
  1. +5 −1 lib/formtastic/inputs/boolean_input.rb
  2. +7 −0 spec/inputs/boolean_input_spec.rb
@@ -50,7 +50,10 @@ def label_with_nested_checkbox
label_html_options
)
end
-
+
+ # TODO: why are we merging `input_html_options` and then making some of the irrelevant ones `nil`?
+ # Seems like we should be selectively including from input_html_options (a whitelist) instead of
+ # excluding (blacklist).
def label_html_options
prev = super
prev[:class] = prev[:class] - ['label']
@@ -59,6 +62,7 @@ def label_html_options
prev.merge(
:id => nil,
:name => nil,
+ :tabindex => nil,
:for => input_html_options[:id]
)
)
@@ -150,6 +150,13 @@
output_buffer.should have_tag('form li label input[@type="checkbox"]')
output_buffer.should have_tag('form li label input[@name="project[allow_comments]"]')
end
+
+ it 'should not pass input_html options down to the label html' do
+ concat(semantic_form_for(@new_post) do |builder|
+ builder.input(:title, :as => :boolean, :input_html => { :tabindex => 2 })
+ end)
+ output_buffer.should_not have_tag('label[tabindex]')
+ end
context "when required" do

0 comments on commit 182b954

Please sign in to comment.