Skip to content
Browse files

Whitelist only `for` and `class` attributes on BooleanInput label.

I can't find a decent reason to be merging with `input_html_options` and fussing around with it like it was.

Closes #995
  • Loading branch information...
1 parent 9904fc4 commit 1d043003aefc2ba59bf0dbd4819c90bba8538dc4 @justinfrench committed Apr 5, 2014
Showing with 6 additions and 15 deletions.
  1. +4 −14 lib/formtastic/inputs/boolean_input.rb
  2. +2 −1 spec/inputs/boolean_input_spec.rb
View
18 lib/formtastic/inputs/boolean_input.rb
@@ -51,21 +51,11 @@ def label_with_nested_checkbox
)
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']
-
- input_html_options.merge(
- prev.merge(
- :id => nil,
- :name => nil,
- :tabindex => nil,
- :for => input_html_options[:id]
- )
- )
+ {
+ :for => input_html_options[:id],
+ :class => super[:class] - ['label'] # remove 'label' class
+ }
end
def label_text_with_embedded_checkbox
View
3 spec/inputs/boolean_input_spec.rb
@@ -153,9 +153,10 @@
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 })
+ builder.input(:title, :as => :boolean, :input_html => { :tabindex => 2, :x => "X" })
end)
output_buffer.should_not have_tag('label[tabindex]')
+ output_buffer.should_not have_tag('label[x]')
end
context "when required" do

0 comments on commit 1d04300

Please sign in to comment.
Something went wrong with that request. Please try again.