app/models/blacklight/icon.rb in blacklight-7.8.1 vs app/models/blacklight/icon.rb in blacklight-7.9.0
- old
+ new
@@ -24,29 +24,25 @@
# Returns an updated version of the svg source
# @return [String]
def svg
svg = ng_xml.at_xpath('svg')
svg['role'] = role
- svg['aria-labelledby'] = unique_id if label
- svg.add_child("<title id='#{unique_id}'>#{icon_label}</title>") if label
+ svg.prepend_child("<title>#{icon_label}</title>") if label
ng_xml.to_xml
end
def icon_label
- I18n.translate("blacklight.icon.#{icon_name_context}", default: "#{icon_name} icon")
+ I18n.translate("blacklight.icon.#{icon_name_context}", default: icon_name.to_s.titleize)
end
- def unique_id
- @unique_id ||= "bl-icon-#{icon_name_context}-#{SecureRandom.hex(8)}"
- end
-
##
# @return [Hash]
def options
{
class: classes,
- "aria-hidden": (true if aria_hidden)
+ "aria-hidden": (true if aria_hidden),
+ "aria-label": (icon_label if label)
}
end
##
# @return [String]
@@ -77,9 +73,9 @@
# This workaround is based off of this comment: https://github.com/fphilipe/premailer-rails/issues/145#issuecomment-225992564
(Rails.application.assets || ::Sprockets::Railtie.build_environment(Rails.application)).find_asset(path)
end
def classes
- " blacklight-icons #{@classes} ".strip
+ " blacklight-icons blacklight-icon-#{icon_name} #{@classes} ".strip
end
end
end