aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_view/helpers')
-rw-r--r--actionpack/lib/action_view/helpers/tag_helper.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/actionpack/lib/action_view/helpers/tag_helper.rb b/actionpack/lib/action_view/helpers/tag_helper.rb
index b00b7636c3..48c65acace 100644
--- a/actionpack/lib/action_view/helpers/tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/tag_helper.rb
@@ -127,9 +127,11 @@ module ActionView
options.each_pair do |key, value|
if key.to_s == 'data' && value.is_a?(Hash)
value.each do |k, v|
- final_v = [String, Symbol].include?(v.class) ? v : v.to_json
- final_v = html_escape(final_v) if escape
- attrs << %(data-#{k.to_s.dasherize}="#{final_v}")
+ if !v.is_a?(String) && !v.is_a?(Symbol)
+ v = v.to_json
+ end
+ v = html_escape(v) if escape
+ attrs << %(data-#{k.to_s.dasherize}="#{v}")
end
elsif BOOLEAN_ATTRIBUTES.include?(key)
attrs << %(#{key}="#{key}") if value