Skip to content

Commit

Permalink
Skip initialisation when GOV.UK Frontend is not supported
Browse files Browse the repository at this point in the history
See approach on GOV.UK Frontend alphagov/govuk-frontend@7e1d0f4
  • Loading branch information
colinrotherham committed Aug 2, 2023
1 parent 475d587 commit e8224f2
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/javascripts/components/back-to-top.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion src/javascripts/components/cookie-banner.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion src/javascripts/components/cookies-page.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion src/javascripts/components/copy.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion src/javascripts/components/example-page.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion src/javascripts/components/example.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion src/javascripts/components/navigation.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion src/javascripts/components/search.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion src/javascripts/components/tabs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit e8224f2

Please sign in to comment.