window.GOVUK = window.GOVUK || {}
window.GOVUK.Modules = window.GOVUK.Modules || {};

(function (GOVUK) {
  'use strict'

  GOVUK.Modules.EnableAriaControls = function EnableAriaControls () {
    this.start = function (element) {
      element.find('[data-aria-controls]').each(enableAriaControls)

      function enableAriaControls () {
        var controls = $(this).data('aria-controls')
        if (typeof controls === 'string' && $('#' + controls).length > 0) {
          $(this).attr('aria-controls', controls)
        }
      }
    }
  }
})(window.GOVUK)

window.GOVUK = window.GOVUK || {}
window.GOVUK.Modules = window.GOVUK.Modules || {};

(function (GOVUK) {
  'use strict'

  GOVUK.Modules.EnableAriaControls = function EnableAriaControls () {
    this.start = function (element) {
      var $controls = element[0].querySelectorAll('[data-aria-controls]')
      for (var i = 0; i < $controls.length; i++) {
        var control = $controls[i].getAttribute('data-aria-controls')
        if (typeof control === 'string' && document.getElementById(control)) {
          $controls[i].setAttribute('aria-controls', control)
        }
      }
    }
  }
})(window.GOVUK)

Remove JQuery from EnableAriaControls module
Remove JQuery from EnableAriaControls module

We're using an old and unsupported version of jQuery for browser support
reasons. Rather than upgrade, it's far better to remove our dependence.

jQuery makes writing JavaScript easier, but it doesn't do anything that
you can't do with vanilla JavaScript, because it's all written in
JavaScript.

Once it's removed, we no longer have to worry about upgrading it, and
users don't have to download the jQuery library when they visit GOV.UK.

Co-authored-by: Andy Sellick <36224b9e2437f61134ff54a3123b9a04319bf263@digital.cabinet-office.gov.uk>
