Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set xlink:href on crown PNG fallback #1337

Merged
merged 2 commits into from
May 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/components/header/template.njk
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

In other browsers <image> is synonymous for the <img> tag and will be
interpreted as such, displaying the fallback image. #}
<image src="{{ params.assetsPath | default('/assets/images') }}/govuk-logotype-crown.png" class="govuk-header__logotype-crown-fallback-image"></image>
<image src="{{ params.assetsPath | default('/assets/images') }}/govuk-logotype-crown.png" xlink:href="" class="govuk-header__logotype-crown-fallback-image"></image>
</svg>
<span class="govuk-header__logotype-text">
GOV.UK
Expand Down
26 changes: 26 additions & 0 deletions src/components/header/template.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <image> 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('')
})
})
})
})