Skip to content

Commit

Permalink
Refactoring the code to avoid some conditionals
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelfranca committed Dec 9, 2020
1 parent aeea158 commit b178a92
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions actionview/lib/action_view/helpers/form_tag_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -934,13 +934,13 @@ def sanitize_to_id(name)
end

def set_default_disable_with(value, tag_options)
data = tag_options["data"]
data = tag_options.fetch("data", {})

if tag_options["data-disable-with"] == false || (data && data["disable_with"] == false)
data.delete("disable_with") if data
if tag_options["data-disable-with"] == false || data["disable_with"] == false
data.delete("disable_with")
elsif ActionView::Base.automatically_disable_submit_tag
disable_with_text = tag_options["data-disable-with"]
disable_with_text ||= data["disable_with"] if data
disable_with_text ||= data["disable_with"]
disable_with_text ||= value.to_s.clone
tag_options.deep_merge!("data" => { "disable_with" => disable_with_text })
end
Expand Down

0 comments on commit b178a92

Please sign in to comment.