diff --git a/src/javascripts/components/back-to-top.mjs b/src/javascripts/components/back-to-top.mjs index 9416e34325..e73e76701d 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 f3b88dee4b..b7d7b4e354 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 b20841ce39..737371221d 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 8f71af427f..edf0593e58 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 c7d6553b1c..842585de12 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 509ecfab40..ac9c98b153 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 1b33dad005..8989a681ca 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 1ac203132d..dc0720a033 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 f454052460..c1f7d95409 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 }