diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b36df3614..40e3577787 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,11 @@ ([PR #1319](https://github.com/alphagov/govuk-frontend/pull/1319)) +- Prevent the fallback PNG image for the crown in the header from being + downloaded unnecessarily in Internet Explorer and Edge. + + ([PR #1337](https://github.com/alphagov/govuk-frontend/pull/1337)) + ## 2.11.0 (Feature release) 🆕 New features: diff --git a/src/components/header/template.njk b/src/components/header/template.njk index 45286d655a..97ed5886bc 100644 --- a/src/components/header/template.njk +++ b/src/components/header/template.njk @@ -40,7 +40,7 @@ In other browsers is synonymous for the tag and will be interpreted as such, displaying the fallback image. #} - + GOV.UK diff --git a/src/components/header/template.test.js b/src/components/header/template.test.js index ce0854ea67..20ded9e69a 100644 --- a/src/components/header/template.test.js +++ b/src/components/header/template.test.js @@ -135,4 +135,30 @@ describe('header', () => { }) }) }) + + describe('SVG logo', () => { + const $ = render('header', {}) + const $svg = $('.govuk-header__logotype-crown') + + it('sets focusable="false" so that IE does not treat it as an interactive element', () => { + expect($svg.attr('focusable')).toEqual('false') + }) + + it('sets role="presentation" so that it is ignored by assistive technologies', () => { + expect($svg.attr('focusable')).toEqual('false') + }) + + describe('fallback PNG', () => { + const $fallbackImage = $('.govuk-header__logotype-crown-fallback-image') + + it('uses the tag which is a valid SVG element', () => { + expect($fallbackImage[0].tagName).toEqual('image') + }) + + it('sets a blank xlink:href to prevent IE from downloading both the SVG and the PNG', () => { + // Cheerio converts xhref to href - https://github.com/cheeriojs/cheerio/issues/1101 + expect($fallbackImage.attr('href')).toEqual('') + }) + }) + }) })