Skip to content

Commit

Permalink
Add more granular messages to SupportError
Browse files Browse the repository at this point in the history
Co-authored-by: Brett Kyle <[email protected]>
Co-authored-by: Colin Rotherham <[email protected]>
  • Loading branch information
domoscargin and colinrotherham committed Nov 24, 2023
1 parent 6b93b36 commit 845fe13
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/govuk-frontend/src/govuk/errors/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,14 @@ export class SupportError extends GOVUKFrontendError {
* @param {HTMLElement | null} [$scope] - HTML element `<body>` checked for browser support
*/
constructor($scope = document.body) {
const supportMessage =
'noModule' in HTMLScriptElement.prototype
? 'GOV.UK Frontend initialised without `<body class="govuk-frontend-supported">` from template `<script>` snippet'
: 'GOV.UK Frontend is not supported in this browser'

super(
$scope
? 'GOV.UK Frontend is not supported in this browser'
? supportMessage
: 'GOV.UK Frontend initialised without `<script type="module">`'
)
}
Expand Down

0 comments on commit 845fe13

Please sign in to comment.