Skip to content

Commit

Permalink
Check that checkbox aria-controls is a conditional
Browse files Browse the repository at this point in the history
Check that the checkbox aria-controls target has the `govuk-checkboxes__conditional` class before trying to toggle the `--hidden` modifier.

This mirrors a similar check that we do for conditional reveals associated with radios, and makes it more robust if e.g. aria-controls is being used for things that are not conditional reveals, now that we're not scoping the aria-controls lookup to the $module.
  • Loading branch information
36degrees committed Jun 24, 2020
1 parent aaff8f9 commit 539a82c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/govuk/components/checkboxes/checkboxes.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Checkboxes.prototype.setAttributes = function ($input) {
$input.setAttribute('aria-expanded', inputIsChecked)

var $content = this.$module.querySelector('#' + $input.getAttribute('aria-controls'))
if ($content) {
if ($content && $content.classList.contains('govuk-checkboxes__conditional')) {
$content.classList.toggle('govuk-checkboxes__conditional--hidden', !inputIsChecked)
}
}
Expand Down

0 comments on commit 539a82c

Please sign in to comment.