diff --git a/src/javascripts/components/back-to-top.mjs b/src/javascripts/components/back-to-top.mjs index 00d8cecbe4..b5f6b9ca78 100644 --- a/src/javascripts/components/back-to-top.mjs +++ b/src/javascripts/components/back-to-top.mjs @@ -6,7 +6,10 @@ 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 3eccb93bf5..cb98de533c 100644 --- a/src/javascripts/components/cookie-banner.mjs +++ b/src/javascripts/components/cookie-banner.mjs @@ -17,6 +17,7 @@ class CookieBanner { constructor($module) { if ( !($module instanceof HTMLElement) || + !document.body.classList.contains('govuk-frontend-supported') || // Exit if we're on the cookies page to avoid circular journeys this.onCookiesPage() ) { diff --git a/src/javascripts/components/cookies-page.mjs b/src/javascripts/components/cookies-page.mjs index 17a4c0e0c7..d7479b1c20 100644 --- a/src/javascripts/components/cookies-page.mjs +++ b/src/javascripts/components/cookies-page.mjs @@ -8,7 +8,10 @@ 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 c08534c802..7dd78ed5ed 100644 --- a/src/javascripts/components/copy.mjs +++ b/src/javascripts/components/copy.mjs @@ -8,7 +8,10 @@ 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 c4f63a4e0b..e03269866f 100644 --- a/src/javascripts/components/example-page.mjs +++ b/src/javascripts/components/example-page.mjs @@ -6,7 +6,10 @@ 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 f780dd3d16..4d38854224 100644 --- a/src/javascripts/components/example.mjs +++ b/src/javascripts/components/example.mjs @@ -13,7 +13,10 @@ 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 121014dc65..8309495e2d 100644 --- a/src/javascripts/components/navigation.mjs +++ b/src/javascripts/components/navigation.mjs @@ -12,7 +12,10 @@ 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 f2c954d04f..f72224d73e 100644 --- a/src/javascripts/components/search.mjs +++ b/src/javascripts/components/search.mjs @@ -41,7 +41,10 @@ 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 c388acd407..8df1593c30 100644 --- a/src/javascripts/components/tabs.mjs +++ b/src/javascripts/components/tabs.mjs @@ -13,7 +13,10 @@ 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 }