From 6de0f2893d39a1d2a3d5e6a9cc08e571d776abf6 Mon Sep 17 00:00:00 2001 From: Chris Beer Date: Thu, 18 Jun 2020 08:22:44 -0700 Subject: [PATCH] Remove redundant aria-labelledby; the title is sufficient on its own --- app/models/blacklight/icon.rb | 7 +------ spec/models/blacklight/icon_spec.rb | 12 ++---------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/app/models/blacklight/icon.rb b/app/models/blacklight/icon.rb index 1d8e441701..3015b3002f 100644 --- a/app/models/blacklight/icon.rb +++ b/app/models/blacklight/icon.rb @@ -26,8 +26,7 @@ def initialize(icon_name, classes: '', aria_hidden: false, label: true, role: 'i def svg svg = ng_xml.at_xpath('svg') svg['role'] = role - svg['aria-labelledby'] = unique_id if label - svg.prepend_child("#{icon_label}") if label + svg.prepend_child("#{icon_label}") if label ng_xml.to_xml end @@ -35,10 +34,6 @@ def icon_label I18n.translate("blacklight.icon.#{icon_name_context}", default: "#{icon_name} icon") end - def unique_id - @unique_id ||= "bl-icon-#{icon_name_context}-#{SecureRandom.hex(8)}" - end - ## # @return [Hash] def options diff --git a/spec/models/blacklight/icon_spec.rb b/spec/models/blacklight/icon_spec.rb index 5e535069a1..8f2abe0b62 100644 --- a/spec/models/blacklight/icon_spec.rb +++ b/spec/models/blacklight/icon_spec.rb @@ -17,11 +17,7 @@ end it 'adds title' do expect(Capybara.string(subject.svg)) - .to have_css 'title[id^="bl-icon-search-"]', text: 'search icon' - end - it 'adds aria-labelledby' do - expect(Capybara.string(subject.svg)) - .to have_css 'svg[aria-labelledby^="bl-icon-search-"]' + .to have_css 'title', text: 'search icon' end context 'when label is false' do subject { described_class.new(:search, classes: 'awesome', aria_hidden: true, label: false) } @@ -30,10 +26,6 @@ expect(Capybara.string(subject.svg)) .not_to have_css 'title', text: 'search icon' end - it 'does not add aria-labelledby' do - expect(Capybara.string(subject.svg)) - .not_to have_css 'svg[aria-labelledby^="bl-icon-search-"]' - end end context ' with a label context' do @@ -41,7 +33,7 @@ it 'adds title' do expect(Capybara.string(subject.svg)) - .to have_css 'title[id^="bl-icon-search_foo-"]', text: 'search icon' + .to have_css 'title', text: 'search icon' end end end