diff --git a/src/javascripts/components/back-to-top.mjs b/src/javascripts/components/back-to-top.mjs index 228be7f88f..66291eb800 100644 --- a/src/javascripts/components/back-to-top.mjs +++ b/src/javascripts/components/back-to-top.mjs @@ -3,7 +3,7 @@ class BackToTop { * @param {Element} $module - HTML element */ constructor ($module) { - if (!($module instanceof HTMLElement)) { + if (!($module instanceof HTMLElement) || !document.body.classList.contains('govuk-frontend-supported')) { return this } diff --git a/src/javascripts/components/cookie-banner.mjs b/src/javascripts/components/cookie-banner.mjs index a58eab24da..3baa2084f3 100644 --- a/src/javascripts/components/cookie-banner.mjs +++ b/src/javascripts/components/cookie-banner.mjs @@ -12,7 +12,7 @@ class CookieBanner { * @param {Element} $module - HTML element */ constructor ($module) { - if (!($module instanceof HTMLElement)) { + if (!($module instanceof HTMLElement) || !document.body.classList.contains('govuk-frontend-supported')) { return this } diff --git a/src/javascripts/components/cookies-page.mjs b/src/javascripts/components/cookies-page.mjs index b57bd53efc..e9ae4c32f4 100644 --- a/src/javascripts/components/cookies-page.mjs +++ b/src/javascripts/components/cookies-page.mjs @@ -5,7 +5,7 @@ class CookiesPage { * @param {Element} $module - HTML element */ constructor ($module) { - if (!($module instanceof HTMLElement)) { + if (!($module instanceof HTMLElement) || !document.body.classList.contains('govuk-frontend-supported')) { return this } diff --git a/src/javascripts/components/copy.mjs b/src/javascripts/components/copy.mjs index 8d72bc6904..bdfa80d6fd 100644 --- a/src/javascripts/components/copy.mjs +++ b/src/javascripts/components/copy.mjs @@ -5,7 +5,7 @@ class Copy { * @param {Element} $module - HTML element */ constructor ($module) { - if (!($module instanceof HTMLElement)) { + if (!($module instanceof HTMLElement) || !document.body.classList.contains('govuk-frontend-supported')) { return this } diff --git a/src/javascripts/components/example-page.mjs b/src/javascripts/components/example-page.mjs index 16172e6fdf..c7f8d9cfa2 100644 --- a/src/javascripts/components/example-page.mjs +++ b/src/javascripts/components/example-page.mjs @@ -3,7 +3,7 @@ class ExamplePage { * @param {Document} $module - HTML document */ constructor ($module) { - if (!($module instanceof Document)) { + if (!($module instanceof Document) || !document.body.classList.contains('govuk-frontend-supported')) { return this } diff --git a/src/javascripts/components/example.mjs b/src/javascripts/components/example.mjs index 0930f0050e..0073e61d3c 100644 --- a/src/javascripts/components/example.mjs +++ b/src/javascripts/components/example.mjs @@ -13,7 +13,7 @@ class Example { * @param {Element} $module - HTML element */ constructor ($module) { - if (!($module instanceof HTMLIFrameElement)) { + if (!($module instanceof HTMLIFrameElement) || !document.body.classList.contains('govuk-frontend-supported')) { return } diff --git a/src/javascripts/components/navigation.mjs b/src/javascripts/components/navigation.mjs index 6f4310e9f8..40fb0db79c 100644 --- a/src/javascripts/components/navigation.mjs +++ b/src/javascripts/components/navigation.mjs @@ -9,7 +9,7 @@ class Navigation { * @param {Document} $module - HTML document */ constructor ($module) { - if (!($module instanceof Document)) { + if (!($module instanceof Document) || !document.body.classList.contains('govuk-frontend-supported')) { return this } diff --git a/src/javascripts/components/search.mjs b/src/javascripts/components/search.mjs index 14cb54bcb7..1fd97c64f9 100644 --- a/src/javascripts/components/search.mjs +++ b/src/javascripts/components/search.mjs @@ -36,7 +36,7 @@ class Search { * @param {Element} $module - HTML element */ constructor ($module) { - if (!($module instanceof HTMLElement)) { + if (!($module instanceof HTMLElement) || !document.body.classList.contains('govuk-frontend-supported')) { return this } diff --git a/src/javascripts/components/tabs.mjs b/src/javascripts/components/tabs.mjs index 2407226c6e..c54652e3ab 100644 --- a/src/javascripts/components/tabs.mjs +++ b/src/javascripts/components/tabs.mjs @@ -14,7 +14,7 @@ class AppTabs { * @param {Element} $module - HTML element */ constructor ($module) { - if (!($module instanceof HTMLElement)) { + if (!($module instanceof HTMLElement) || !document.body.classList.contains('govuk-frontend-supported')) { return this } diff --git a/src/styles/page-template/index.md b/src/styles/page-template/index.md index cb5b74fd82..ee2bf0e432 100644 --- a/src/styles/page-template/index.md +++ b/src/styles/page-template/index.md @@ -12,7 +12,7 @@ Use this template to keep your pages consistent with the rest of GOV.UK. This page template combines the boilerplate markup and [components](/components/) needed for a basic GOV.UK page. It includes: -- JavaScript that adds a `.js-enabled` class, which is required by components with JavaScript behaviour +- JavaScript that adds a `.govuk-frontend-supported` class, which is required by components with JavaScript behaviour - the [skip link](/components/skip-link/), [header](/components/header/) and [footer](/components/footer/) components - the favicon, and other related theme icons diff --git a/src/stylesheets/components/_back-to-top.scss b/src/stylesheets/components/_back-to-top.scss index a4b5e22cd9..abab7e00e6 100644 --- a/src/stylesheets/components/_back-to-top.scss +++ b/src/stylesheets/components/_back-to-top.scss @@ -12,14 +12,14 @@ margin-bottom: govuk-spacing(8); } - .js-enabled .app-back-to-top--fixed { + .govuk-frontend-supported .app-back-to-top--fixed { position: fixed; top: calc(100% - #{govuk-spacing(8)}); bottom: auto; left: auto; } - .js-enabled .app-back-to-top--hidden .app-back-to-top__link { + .govuk-frontend-supported .app-back-to-top--hidden .app-back-to-top__link { @include govuk-visually-hidden-focusable; } } diff --git a/src/stylesheets/components/_navigation.scss b/src/stylesheets/components/_navigation.scss index 16f7b62bcb..eee2885f4b 100644 --- a/src/stylesheets/components/_navigation.scss +++ b/src/stylesheets/components/_navigation.scss @@ -78,12 +78,12 @@ list-style: none; } -.js-enabled .app-navigation__subnav--active { +.govuk-frontend-supported .app-navigation__subnav--active { display: block; } .app-navigation__subnav, -.js-enabled .app-navigation__subnav--active { +.govuk-frontend-supported .app-navigation__subnav--active { @include govuk-media-query($from: tablet) { display: none; } diff --git a/src/stylesheets/components/_site-search.scss b/src/stylesheets/components/_site-search.scss index 79d0559fdc..a6b54412f4 100644 --- a/src/stylesheets/components/_site-search.scss +++ b/src/stylesheets/components/_site-search.scss @@ -21,7 +21,7 @@ $icon-size: 40px; margin-bottom: govuk-spacing(2); float: left; - .js-enabled & { + .govuk-frontend-supported & { display: block; } @@ -37,7 +37,7 @@ $icon-size: 40px; float: right; text-align: right; - .js-enabled & { + .govuk-frontend-supported & { text-align: left; } } @@ -205,7 +205,7 @@ $icon-size: 40px; @include govuk-media-query($from: tablet) { display: inline-block; - .js-enabled & { + .govuk-frontend-supported & { display: none; } } diff --git a/src/stylesheets/main.scss b/src/stylesheets/main.scss index bbb0750e3c..368e226a3b 100644 --- a/src/stylesheets/main.scss +++ b/src/stylesheets/main.scss @@ -275,7 +275,7 @@ pre code { outline: $govuk-focus-width solid $govuk-focus-colour; } - .js-enabled [data-module="app-copy"] & { + .govuk-frontend-supported [data-module="app-copy"] & { padding-top: 45px; // Allow extra space for the copy code button } }