diff --git a/docs/contributing/coding-standards/js.md b/docs/contributing/coding-standards/js.md index de29e1aef2..1e413d5bb6 100644 --- a/docs/contributing/coding-standards/js.md +++ b/docs/contributing/coding-standards/js.md @@ -15,9 +15,12 @@ component ```mjs /** * Component name + * + * @preserve */ export class Example { /** + * @preserve * @param {Element} $module - HTML element to use for component */ constructor ($module) { @@ -32,6 +35,8 @@ export class Example { /** * Initialise component + * + * @preserve */ init () { // Check that required elements are present diff --git a/packages/govuk-frontend/src/govuk/components/accordion/accordion.mjs b/packages/govuk-frontend/src/govuk/components/accordion/accordion.mjs index 49b52be968..50d1932680 100644 --- a/packages/govuk-frontend/src/govuk/components/accordion/accordion.mjs +++ b/packages/govuk-frontend/src/govuk/components/accordion/accordion.mjs @@ -13,6 +13,8 @@ import { I18n } from '../../i18n.mjs' * * The state of each section is saved to the DOM via the `aria-expanded` * attribute, which also provides accessibility. + * + * @preserve */ export class Accordion { /** @private */ @@ -109,6 +111,7 @@ export class Accordion { $showAllText = null /** + * @preserve * @param {Element} $module - HTML element to use for accordion * @param {AccordionConfig} [config] - Accordion config */ @@ -138,6 +141,8 @@ export class Accordion { /** * Initialise component + * + * @preserve */ init () { // Check that required elements are present diff --git a/packages/govuk-frontend/src/govuk/components/button/button.mjs b/packages/govuk-frontend/src/govuk/components/button/button.mjs index 99af1fbef9..dbee7e816a 100644 --- a/packages/govuk-frontend/src/govuk/components/button/button.mjs +++ b/packages/govuk-frontend/src/govuk/components/button/button.mjs @@ -6,6 +6,8 @@ const DEBOUNCE_TIMEOUT_IN_SECONDS = 1 /** * JavaScript enhancements for the Button component + * + * @preserve */ export class Button { /** @private */ @@ -24,7 +26,7 @@ export class Button { debounceFormSubmitTimer = null /** - * + * @preserve * @param {Element} $module - HTML element to use for button * @param {ButtonConfig} [config] - Button config */ @@ -44,6 +46,8 @@ export class Button { /** * Initialise component + * + * @preserve */ init () { // Check that required elements are present diff --git a/packages/govuk-frontend/src/govuk/components/character-count/character-count.mjs b/packages/govuk-frontend/src/govuk/components/character-count/character-count.mjs index 5df1f0d195..e6dbf2f542 100644 --- a/packages/govuk-frontend/src/govuk/components/character-count/character-count.mjs +++ b/packages/govuk-frontend/src/govuk/components/character-count/character-count.mjs @@ -12,6 +12,8 @@ import { I18n } from '../../i18n.mjs' * * You can configure the message to only appear after a certain percentage * of the available characters/words has been entered. + * + * @preserve */ export class CharacterCount { /** @private */ @@ -60,6 +62,7 @@ export class CharacterCount { maxLength = Infinity /** + * @preserve * @param {Element} $module - HTML element to use for character count * @param {CharacterCountConfig} [config] - Character count config */ @@ -123,6 +126,8 @@ export class CharacterCount { /** * Initialise component + * + * @preserve */ init () { // Check that required elements are present diff --git a/packages/govuk-frontend/src/govuk/components/checkboxes/checkboxes.mjs b/packages/govuk-frontend/src/govuk/components/checkboxes/checkboxes.mjs index f49cfb671c..36486d7de5 100644 --- a/packages/govuk-frontend/src/govuk/components/checkboxes/checkboxes.mjs +++ b/packages/govuk-frontend/src/govuk/components/checkboxes/checkboxes.mjs @@ -1,5 +1,7 @@ /** * Checkboxes component + * + * @preserve */ export class Checkboxes { /** @private */ @@ -9,6 +11,7 @@ export class Checkboxes { $inputs /** + * @preserve * @param {Element} $module - HTML element to use for checkboxes */ constructor ($module) { @@ -39,6 +42,8 @@ export class Checkboxes { * We also need to restore the state of any conditional reveals on the page (for * example if the user has navigated back), and set up event handlers to keep * the reveal in sync with the checkbox state. + * + * @preserve */ init () { // Check that required elements are present diff --git a/packages/govuk-frontend/src/govuk/components/error-summary/error-summary.mjs b/packages/govuk-frontend/src/govuk/components/error-summary/error-summary.mjs index 56459579d3..d36155eeb5 100644 --- a/packages/govuk-frontend/src/govuk/components/error-summary/error-summary.mjs +++ b/packages/govuk-frontend/src/govuk/components/error-summary/error-summary.mjs @@ -5,6 +5,8 @@ import { normaliseDataset } from '../../common/normalise-dataset.mjs' * Error summary component * * Takes focus on initialisation for accessible announcement, unless disabled in configuration. + * + * @preserve */ export class ErrorSummary { /** @private */ @@ -17,7 +19,7 @@ export class ErrorSummary { config /** - * + * @preserve * @param {Element} $module - HTML element to use for error summary * @param {ErrorSummaryConfig} [config] - Error summary config */ @@ -44,6 +46,8 @@ export class ErrorSummary { /** * Initialise component + * + * @preserve */ init () { // Check that required elements are present diff --git a/packages/govuk-frontend/src/govuk/components/exit-this-page/exit-this-page.mjs b/packages/govuk-frontend/src/govuk/components/exit-this-page/exit-this-page.mjs index c53f6f1edc..d9a25dd0bc 100644 --- a/packages/govuk-frontend/src/govuk/components/exit-this-page/exit-this-page.mjs +++ b/packages/govuk-frontend/src/govuk/components/exit-this-page/exit-this-page.mjs @@ -4,6 +4,8 @@ import { I18n } from '../../i18n.mjs' /** * Exit This Page component + * + * @preserve */ export class ExitThisPage { /** @private */ @@ -71,6 +73,7 @@ export class ExitThisPage { timeoutMessageId = null /** + * @preserve * @param {Element} $module - HTML element that wraps the Exit This Page button * @param {ExitThisPageConfig} [config] - Exit This Page config */ @@ -102,6 +105,8 @@ export class ExitThisPage { /** * Initialise component + * + * @preserve */ init () { this.buildIndicator() diff --git a/packages/govuk-frontend/src/govuk/components/header/header.mjs b/packages/govuk-frontend/src/govuk/components/header/header.mjs index 803b028c74..caf68a3e88 100644 --- a/packages/govuk-frontend/src/govuk/components/header/header.mjs +++ b/packages/govuk-frontend/src/govuk/components/header/header.mjs @@ -1,5 +1,7 @@ /** * Header component + * + * @preserve */ export class Header { /** @private */ @@ -32,6 +34,7 @@ export class Header { mql = null /** + * @preserve * @param {Element} $module - HTML element to use for header */ constructor ($module) { @@ -53,6 +56,8 @@ export class Header { * missing then there's nothing to do so return early. * Apply a matchMedia for desktop which will trigger a state sync if the browser * viewport moves between states. + * + * @preserve */ init () { // Check that required elements are present diff --git a/packages/govuk-frontend/src/govuk/components/notification-banner/notification-banner.mjs b/packages/govuk-frontend/src/govuk/components/notification-banner/notification-banner.mjs index 7fdee3ac74..5925212604 100644 --- a/packages/govuk-frontend/src/govuk/components/notification-banner/notification-banner.mjs +++ b/packages/govuk-frontend/src/govuk/components/notification-banner/notification-banner.mjs @@ -3,6 +3,8 @@ import { normaliseDataset } from '../../common/normalise-dataset.mjs' /** * Notification Banner component + * + * @preserve */ export class NotificationBanner { /** @private */ @@ -15,6 +17,7 @@ export class NotificationBanner { config /** + * @preserve * @param {Element} $module - HTML element to use for notification banner * @param {NotificationBannerConfig} [config] - Notification banner config */ @@ -34,6 +37,8 @@ export class NotificationBanner { /** * Initialise component + * + * @preserve */ init () { // Check that required elements are present diff --git a/packages/govuk-frontend/src/govuk/components/radios/radios.mjs b/packages/govuk-frontend/src/govuk/components/radios/radios.mjs index 52576d0364..931e3603a4 100644 --- a/packages/govuk-frontend/src/govuk/components/radios/radios.mjs +++ b/packages/govuk-frontend/src/govuk/components/radios/radios.mjs @@ -1,5 +1,7 @@ /** * Radios component + * + * @preserve */ export class Radios { /** @private */ @@ -9,6 +11,7 @@ export class Radios { $inputs /** + * @preserve * @param {Element} $module - HTML element to use for radios */ constructor ($module) { @@ -39,6 +42,8 @@ export class Radios { * We also need to restore the state of any conditional reveals on the page (for * example if the user has navigated back), and set up event handlers to keep * the reveal in sync with the radio state. + * + * @preserve */ init () { // Check that required elements are present diff --git a/packages/govuk-frontend/src/govuk/components/skip-link/skip-link.mjs b/packages/govuk-frontend/src/govuk/components/skip-link/skip-link.mjs index 0fe255c633..b45a912614 100644 --- a/packages/govuk-frontend/src/govuk/components/skip-link/skip-link.mjs +++ b/packages/govuk-frontend/src/govuk/components/skip-link/skip-link.mjs @@ -1,5 +1,7 @@ /** * Skip link component + * + * @preserve */ export class SkipLink { /** @private */ @@ -15,7 +17,7 @@ export class SkipLink { linkedElementListener = false /** - * + * @preserve * @param {Element} $module - HTML element to use for skip link */ constructor ($module) { @@ -28,6 +30,8 @@ export class SkipLink { /** * Initialise component + * + * @preserve */ init () { // Check that required elements are present diff --git a/packages/govuk-frontend/src/govuk/components/tabs/tabs.mjs b/packages/govuk-frontend/src/govuk/components/tabs/tabs.mjs index 23e726affe..79b0134cd8 100644 --- a/packages/govuk-frontend/src/govuk/components/tabs/tabs.mjs +++ b/packages/govuk-frontend/src/govuk/components/tabs/tabs.mjs @@ -1,5 +1,7 @@ /** * Tabs component + * + * @preserve */ export class Tabs { /** @private */ @@ -33,6 +35,7 @@ export class Tabs { mql = null /** + * @preserve * @param {Element} $module - HTML element to use for tabs */ constructor ($module) { @@ -57,6 +60,8 @@ export class Tabs { /** * Initialise component + * + * @preserve */ init () { // Check that required elements are present diff --git a/packages/govuk-frontend/src/govuk/i18n.mjs b/packages/govuk-frontend/src/govuk/i18n.mjs index eb922ee142..a3d5d39b7c 100644 --- a/packages/govuk-frontend/src/govuk/i18n.mjs +++ b/packages/govuk-frontend/src/govuk/i18n.mjs @@ -2,6 +2,7 @@ * Internal support for selecting messages to render, with placeholder * interpolation and locale-aware number formatting and pluralisation * + * @preserve * @private */ export class I18n { @@ -9,6 +10,7 @@ export class I18n { locale /** + * @preserve * @param {{ [key: string]: unknown }} translations - Key-value pairs of the translation strings to use. * @param {object} [config] - Configuration options for the function. * @param {string} [config.locale] - An overriding locale for the PluralRules functionality.