Skip to content

Commit

Permalink
Add attributes support to the Exit this Page button
Browse files Browse the repository at this point in the history
  • Loading branch information
querkmachine committed Aug 7, 2023
1 parent a38f59c commit b06717c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ params:
type: object
required: false
description: HTML attributes (for example data attributes) to add to the exit this page container.
- name: button.attributes
type: object
required: false
description: Options for the exit this page button.
params:
- name: attributes
type: object
required: false
description: HTML attributes (for example data attributes) to add to the exit this page button. The default disables referrer information being provided to the `redirectUrl` and tells search engines to ignore the page being linked to.
- name: activatedText
type: string
required: false
Expand Down Expand Up @@ -66,6 +75,10 @@ examples:
classes: 'test-class'
attributes:
test-attribute: true
button:
attributes:
rel: 'nofollow noreferrer noopener'
test-attribute: true
- name: testing-html
hidden: true
data:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
html: params.html if (params.html or params.text) else defaultHtml,
text: params.text,
classes: "govuk-button--warning govuk-exit-this-page__button govuk-js-exit-this-page-button",
href: params.redirectUrl | default("https://www.bbc.co.uk/weather")
href: params.redirectUrl | default("https://www.bbc.co.uk/weather"),
attributes: params.button.attributes | default({ 'rel': 'nofollow noreferrer' })
}) -}}
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe('Exit this page', () => {
expect($button.hasClass('govuk-button--warning')).toBeTruthy()
expect($button.html()).toContain('<span class="govuk-visually-hidden">Emergency</span> Exit this page')
expect($button.attr('href')).toBe('/full-page-examples/announcements')
expect($button.attr('rel')).toBe('nofollow noreferrer')
})
})

Expand Down Expand Up @@ -61,6 +62,14 @@ describe('Exit this page', () => {

expect($component.attr('test-attribute')).toBe('true')
})

it('renders with custom button attributes', () => {
const $ = render('exit-this-page', examples.testing)
const $button = $('.govuk-exit-this-page').find('.govuk-button')

expect($button.attr('rel')).toBe('nofollow noreferrer noopener')
expect($button.attr('test-attribute')).toBe('true')
})
})

describe('Translated', () => {
Expand Down

0 comments on commit b06717c

Please sign in to comment.