From ee61b76a810ad67ca064be2922a8b481fa840043 Mon Sep 17 00:00:00 2001 From: PaoMar Date: Wed, 3 Sep 2014 15:03:58 -0500 Subject: Add support for ARIA attributes in tags --- actionview/lib/action_view/helpers/tag_helper.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'actionview/lib/action_view/helpers/tag_helper.rb') diff --git a/actionview/lib/action_view/helpers/tag_helper.rb b/actionview/lib/action_view/helpers/tag_helper.rb index 268558669e..f200d424c0 100644 --- a/actionview/lib/action_view/helpers/tag_helper.rb +++ b/actionview/lib/action_view/helpers/tag_helper.rb @@ -148,9 +148,9 @@ module ActionView return if options.blank? attrs = [] options.each_pair do |key, value| - if key.to_s == 'data' && value.is_a?(Hash) + if (key.to_s == 'data' || key.to_s == 'aria') && value.is_a?(Hash) value.each_pair do |k, v| - attrs << data_tag_option(k, v, escape) + attrs << prefix_tag_option(key, k, v, escape) end elsif BOOLEAN_ATTRIBUTES.include?(key) attrs << boolean_tag_option(key) if value @@ -161,8 +161,8 @@ module ActionView " #{attrs.sort! * ' '}" unless attrs.empty? end - def data_tag_option(key, value, escape) - key = "data-#{key.to_s.dasherize}" + def prefix_tag_option(prefix, key, value, escape) + key = "#{prefix}-#{key.to_s.dasherize}" unless value.is_a?(String) || value.is_a?(Symbol) || value.is_a?(BigDecimal) value = value.to_json end -- cgit v1.2.3