1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Refactoring the code to avoid some conditionals

This commit is contained in:
Rafael Mendonça França 2020-12-09 18:43:09 +00:00
parent aeea158d95
commit b178a92428
No known key found for this signature in database
GPG key ID: FC23B6D0F1EEE948

View file

@ -934,13 +934,13 @@ module ActionView
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