-
Notifications
You must be signed in to change notification settings - Fork 328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add class .govuk-frontend-supported
for ES modules support
#3801
Conversation
69e704a
to
c07fa70
Compare
c07fa70
to
7694c09
Compare
7694c09
to
623640e
Compare
Do we need to follow our own advice and use the Noticed whilst updating test setup to include the new class: document.body.classList.add('govuk-frontend-supported')
$textarea.classList.add('govuk-js-character-count') Side-by-side it looks like a typo |
623640e
to
1075efd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking neat! 🙌🏻 Just added a little comment to clarify comments in the Character count test (but pre-approving). I think this closes #3509 as well, as any further discussion on what the component does when it can't initialise can be handled as part of our work on the component's public API #3479.
// Component checks that required elements are present | ||
document.body.classList.add('govuk-frontend-supported') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Component checks that required elements are present | |
document.body.classList.add('govuk-frontend-supported') | |
// Component checks that GOV.UK Frontend is supported | |
document.body.classList.add('govuk-frontend-supported') | |
// Component checks that required elements are present |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine by me. Were you happy that we don't comply with our .govuk-js-*
prefix in #3801 (comment)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, I think that's fine as the purpose of each class is different:
govuk-js-*
for JS to grab specific HTML elements (and shouldn't be used for styling)govuk-frontend-supported
set by JS to hook styles, so shouldn't have the-js-
bit (we happen to re-use it for checking if we're supported; we could have set awindow.GOVUKFrontendSupported = true
but that makes the snippet longer)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Brill, that's what I figured
Other services can freely use .govuk-js-*
as advised by us
But we may see other "support classes" such as:
.govuk-frontend-supported
.govuk-prototype-kit-supported
.govuk-design-system-supported
.govuk-supported
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think that'll be perfectly fine if these classes pop up as well, allowing services to have their own cut on top of ours (hopefully coordinating with ours, though 😆 ). ⛵
Additionally detects `'noModule' in HTMLScriptElement.prototype` (Safari 11+) rather than just baseline `<script type="module">` support
This closes the support gap for browsers without ES module support still loading JavaScript-only styles
1075efd
to
7e1d0f4
Compare
Thanks @romaricpascal Let's merge this for now but aware we may still tighten the checks after: For example we talked about raising the ES2015 bar to perhaps ES2018? Reducing polyfillsFor example this rough ES2018 feature detect for 'Promise' in window && 'finally' in window.Promise.prototype Would give us loose assurance of the following:
ES2015 to ES2018 support gapQuerying against |
…xes) Updates the Checkboxes component missed from: * #3801
…xes) Updates the Checkboxes component missed from: * #3801
This PR updates the
.js-enabled
inline<script>
to also append.govuk-frontend-supported
Only browsers with
<script nomodule>
support now run our JavaScript, which closes:By additionally detecting
'noModule' in HTMLScriptElement.prototype
(Safari 11+) we can "cut the mustard" and prevent early ES2015 class implementations from loading our components