diff options
author | Michael Koziarski <michael@koziarski.com> | 2010-10-18 11:17:13 +1300 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2010-10-18 11:18:43 +1300 |
commit | 2f9e880431f7a53e470164203ea82be3d2d0ca3a (patch) | |
tree | 7915bb34d7bd679be889ea4c881f3ebd2a5ffcb3 /actionpack | |
parent | 5e79094fc1dbb62e27cf21c0f18b586a26d5de46 (diff) | |
download | rails-2f9e880431f7a53e470164203ea82be3d2d0ca3a.tar.gz rails-2f9e880431f7a53e470164203ea82be3d2d0ca3a.tar.bz2 rails-2f9e880431f7a53e470164203ea82be3d2d0ca3a.zip |
Rejig the html5 data helper code
Avoid allocating an array each pass through and support String subclasses like SafeBuffers
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_view/helpers/tag_helper.rb | 8 |
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 |