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

Update components to only initialise where GOV.UK Frontend is supported #3509

Closed
1 of 2 tasks
Tracked by #2639
romaricpascal opened this issue Apr 14, 2023 · 1 comment
Closed
1 of 2 tasks
Tracked by #2639
Milestone

Comments

@romaricpascal
Copy link
Member

romaricpascal commented Apr 14, 2023

What

Prevent components from initialising where GOV.UK Frontend is not supported.

Services may know whether we’ll initialise or not using the presence of govuk-frontend-supported on the <body>.

Note: We may complement this with either an IS_SUPPORTED boolean or isSupported() function so both us and services share the same value for sure.

Why

Support for noNodule is not quite the same as support for <script type=”module”>, with Safari 10.1 supporting the later but not the former. This means we’ll need to guard our component’s initialisation the same way we guard the addition of the styling class. Otherwise, we’ll risk running our JavaScript against elements that have not been styled anticipating the JavaScript to run.

Who needs to work on this

Developers

Who needs to review this

Developers

Depends on

Done when

  1. Components only initialise where GOV.UK Frontend is supported
@colinrotherham
Copy link
Contributor

We completed this in:

I'll remove the dependency on #3479 as we can still look to abstract our checks into isSupported() in future:

if (!($module instanceof HTMLElement) || !isSupported()) {
  return this
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

2 participants