-
Notifications
You must be signed in to change notification settings - Fork 324
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
Rename $module
to $root
across the codebase
#5337
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
govuk-design-system-ci
temporarily deployed
to
govuk-frontend-pr-5337
September 20, 2024 10:44
Inactive
📋 StatsFile sizes
Modules
View stats and visualisations on the review app Action run for 73f79a7 |
JavaScript changes to npm packagediff --git a/packages/govuk-frontend/dist/govuk/govuk-frontend.min.js b/packages/govuk-frontend/dist/govuk/govuk-frontend.min.js
index 19e286ee0..675ccb955 100644
--- a/packages/govuk-frontend/dist/govuk/govuk-frontend.min.js
+++ b/packages/govuk-frontend/dist/govuk/govuk-frontend.min.js
@@ -1,9 +1,9 @@
const version = "development";
-function normaliseString(e, t) {
- const n = e ? e.trim() : "";
- let i, s = null == t ? void 0 : t.type;
- switch (s || (["true", "false"].includes(n) && (s = "boolean"), n.length > 0 && isFinite(Number(n)) && (s = "number")), s) {
+function normaliseString(t, e) {
+ const n = t ? t.trim() : "";
+ let i, o = null == e ? void 0 : e.type;
+ switch (o || (["true", "false"].includes(n) && (o = "boolean"), n.length > 0 && isFinite(Number(n)) && (o = "number")), o) {
case "boolean":
i = "true" === n;
break;
@@ -11,129 +11,129 @@ function normaliseString(e, t) {
i = Number(n);
break;
default:
- i = e
+ i = t
}
return i
}
-function mergeConfigs(...e) {
- const t = {};
- for (const n of e)
- for (const e of Object.keys(n)) {
- const i = t[e],
- s = n[e];
- isObject(i) && isObject(s) ? t[e] = mergeConfigs(i, s) : t[e] = s
+function mergeConfigs(...t) {
+ const e = {};
+ for (const n of t)
+ for (const t of Object.keys(n)) {
+ const i = e[t],
+ o = n[t];
+ isObject(i) && isObject(o) ? e[t] = mergeConfigs(i, o) : e[t] = o
}
- return t
+ return e
}
-function extractConfigByNamespace(e, t, n) {
- const i = e.schema.properties[n];
+function extractConfigByNamespace(t, e, n) {
+ const i = t.schema.properties[n];
if ("object" !== (null == i ? void 0 : i.type)) return;
- const s = {
+ const o = {
[n]: {}
};
- for (const [o, r] of Object.entries(t)) {
- let e = s;
- const t = o.split(".");
- for (const [i, s] of t.entries()) "object" == typeof e && (i < t.length - 1 ? (isObject(e[s]) || (e[s] = {}), e = e[s]) : o !== n && (e[s] = normaliseString(r)))
+ for (const [s, r] of Object.entries(e)) {
+ let t = o;
+ const e = s.split(".");
+ for (const [i, o] of e.entries()) "object" == typeof t && (i < e.length - 1 ? (isObject(t[o]) || (t[o] = {}), t = t[o]) : s !== n && (t[o] = normaliseString(r)))
}
- return s[n]
+ return o[n]
}
-function getFragmentFromUrl(e) {
- if (e.includes("#")) return e.split("#").pop()
+function getFragmentFromUrl(t) {
+ if (t.includes("#")) return t.split("#").pop()
}
-function getBreakpoint(e) {
- const t = `--govuk-frontend-breakpoint-${e}`;
+function getBreakpoint(t) {
+ const e = `--govuk-frontend-breakpoint-${t}`;
return {
- property: t,
- value: window.getComputedStyle(document.documentElement).getPropertyValue(t) || void 0
+ property: e,
+ value: window.getComputedStyle(document.documentElement).getPropertyValue(e) || void 0
}
}
-function setFocus(e, t = {}) {
+function setFocus(t, e = {}) {
var n;
- const i = e.getAttribute("tabindex");
+ const i = t.getAttribute("tabindex");
function onBlur() {
var n;
- null == (n = t.onBlur) || n.call(e), i || e.removeAttribute("tabindex")
+ null == (n = e.onBlur) || n.call(t), i || t.removeAttribute("tabindex")
}
- i || e.setAttribute("tabindex", "-1"), e.addEventListener("focus", (function() {
- e.addEventListener("blur", onBlur, {
+ i || t.setAttribute("tabindex", "-1"), t.addEventListener("focus", (function() {
+ t.addEventListener("blur", onBlur, {
once: !0
})
}), {
once: !0
- }), null == (n = t.onBeforeFocus) || n.call(e), e.focus()
+ }), null == (n = e.onBeforeFocus) || n.call(t), t.focus()
}
-function isSupported(e = document.body) {
- return !!e && e.classList.contains("govuk-frontend-supported")
+function isSupported(t = document.body) {
+ return !!t && t.classList.contains("govuk-frontend-supported")
}
-function isObject(e) {
- return !!e && "object" == typeof e && ! function(e) {
- return Array.isArray(e)
- }(e)
+function isObject(t) {
+ return !!t && "object" == typeof t && ! function(t) {
+ return Array.isArray(t)
+ }(t)
}
-function normaliseDataset(e, t) {
+function normaliseDataset(t, e) {
const n = {};
- for (const [i, s] of Object.entries(e.schema.properties)) i in t && (n[i] = normaliseString(t[i], s)), "object" === (null == s ? void 0 : s.type) && (n[i] = extractConfigByNamespace(e, t, i));
+ for (const [i, o] of Object.entries(t.schema.properties)) i in e && (n[i] = normaliseString(e[i], o)), "object" === (null == o ? void 0 : o.type) && (n[i] = extractConfigByNamespace(t, e, i));
return n
}
class GOVUKFrontendError extends Error {
- constructor(...e) {
- super(...e), this.name = "GOVUKFrontendError"
+ constructor(...t) {
+ super(...t), this.name = "GOVUKFrontendError"
}
}
class SupportError extends GOVUKFrontendError {
- constructor(e = document.body) {
- const t = "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(e ? t : 'GOV.UK Frontend initialised without `<script type="module">`'), this.name = "SupportError"
+ constructor(t = document.body) {
+ const e = "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(t ? e : 'GOV.UK Frontend initialised without `<script type="module">`'), this.name = "SupportError"
}
}
class ConfigError extends GOVUKFrontendError {
- constructor(...e) {
- super(...e), this.name = "ConfigError"
+ constructor(...t) {
+ super(...t), this.name = "ConfigError"
}
}
class ElementError extends GOVUKFrontendError {
- constructor(e) {
- let t = "string" == typeof e ? e : "";
- if ("object" == typeof e) {
+ constructor(t) {
+ let e = "string" == typeof t ? t : "";
+ if ("object" == typeof t) {
const {
componentName: n,
identifier: i,
- element: s,
- expectedType: o
- } = e;
- t = `${n}: ${i}`, t += s ? ` is not of type ${null!=o?o:"HTMLElement"}` : " not found"
+ element: o,
+ expectedType: s
+ } = t;
+ e = `${n}: ${i}`, e += o ? ` is not of type ${null!=s?s:"HTMLElement"}` : " not found"
}
- super(t), this.name = "ElementError"
+ super(e), this.name = "ElementError"
}
}
class InitError extends GOVUKFrontendError {
- constructor(e, t) {
- let n = `moduleName not defined in component (\`${t}\`)`;
- "string" == typeof e && (n = `Root element (\`$module\`) already initialised (\`${e}\`)`), super(n), this.name = "InitError"
+ constructor(t, e) {
+ let n = `moduleName not defined in component (\`${e}\`)`;
+ "string" == typeof t && (n = `Root element (\`$root\`) already initialised (\`${t}\`)`), super(n), this.name = "InitError"
}
}
class GOVUKFrontendComponent {
- constructor(e) {
- this.checkSupport(), this.checkInitialised(e);
- const t = this.constructor.moduleName;
- if ("string" != typeof t) throw new InitError(t);
- t && (null == e || e.setAttribute(`data-${t}-init`, ""))
- }
- checkInitialised(e) {
- const t = this.constructor.moduleName;
- if (e && t && function(e, t) {
- return e instanceof HTMLElement && e.hasAttribute(`data-${t}-init`)
- }(e, t)) throw new InitError(t)
+ constructor(t) {
+ this.checkSupport(), this.checkInitialised(t);
+ const e = this.constructor.moduleName;
+ if ("string" != typeof e) throw new InitError(e);
+ e && (null == t || t.setAttribute(`data-${e}-init`, ""))
+ }
+ checkInitialised(t) {
+ const e = this.constructor.moduleName;
+ if (t && e && function(t, e) {
+ return t instanceof HTMLElement && t.hasAttribute(`data-${e}-init`)
+ }(t, e)) throw new InitError(e)
}
checkSupport() {
if (!this.isSupported()) throw new SupportError
@@ -143,59 +143,59 @@ class GOVUKFrontendComponent {
}
}
class I18n {
- constructor(e = {}, t = {}) {
+ constructor(t = {}, e = {}) {
var n;
- this.translations = void 0, this.locale = void 0, this.translations = e, this.locale = null != (n = t.locale) ? n : document.documentElement.lang || "en"
+ this.translations = void 0, this.locale = void 0, this.translations = t, this.locale = null != (n = e.locale) ? n : document.documentElement.lang || "en"
}
- t(e, t) {
- if (!e) throw new Error("i18n: lookup key missing");
- let n = this.translations[e];
- if ("number" == typeof(null == t ? void 0 : t.count) && "object" == typeof n) {
- const i = n[this.getPluralSuffix(e, t.count)];
+ t(t, e) {
+ if (!t) throw new Error("i18n: lookup key missing");
+ let n = this.translations[t];
+ if ("number" == typeof(null == e ? void 0 : e.count) && "object" == typeof n) {
+ const i = n[this.getPluralSuffix(t, e.count)];
i && (n = i)
}
if ("string" == typeof n) {
if (n.match(/%{(.\S+)}/)) {
- if (!t) throw new Error("i18n: cannot replace placeholders in string if no option data provided");
- return this.replacePlaceholders(n, t)
+ if (!e) throw new Error("i18n: cannot replace placeholders in string if no option data provided");
+ return this.replacePlaceholders(n, e)
}
return n
}
- return e
+ return t
}
- replacePlaceholders(e, t) {
+ replacePlaceholders(t, e) {
const n = Intl.NumberFormat.supportedLocalesOf(this.locale).length ? new Intl.NumberFormat(this.locale) : void 0;
- return e.replace(/%{(.\S+)}/g, (function(e, i) {
- if (Object.prototype.hasOwnProperty.call(t, i)) {
- const e = t[i];
- return !1 === e || "number" != typeof e && "string" != typeof e ? "" : "number" == typeof e ? n ? n.format(e) : `${e}` : e
+ return t.replace(/%{(.\S+)}/g, (function(t, i) {
+ if (Object.prototype.hasOwnProperty.call(e, i)) {
+ const t = e[i];
+ return !1 === t || "number" != typeof t && "string" != typeof t ? "" : "number" == typeof t ? n ? n.format(t) : `${t}` : t
}
- throw new Error(`i18n: no data found to replace ${e} placeholder in string`)
+ throw new Error(`i18n: no data found to replace ${t} placeholder in string`)
}))
}
hasIntlPluralRulesSupport() {
return Boolean("PluralRules" in window.Intl && Intl.PluralRules.supportedLocalesOf(this.locale).length)
}
- getPluralSuffix(e, t) {
- if (t = Number(t), !isFinite(t)) return "other";
- const n = this.translations[e],
- i = this.hasIntlPluralRulesSupport() ? new Intl.PluralRules(this.locale).select(t) : this.selectPluralFormUsingFallbackRules(t);
+ getPluralSuffix(t, e) {
+ if (e = Number(e), !isFinite(e)) return "other";
+ const n = this.translations[t],
+ i = this.hasIntlPluralRulesSupport() ? new Intl.PluralRules(this.locale).select(e) : this.selectPluralFormUsingFallbackRules(e);
if ("object" == typeof n) {
if (i in n) return i;
if ("other" in n) return console.warn(`i18n: Missing plural form ".${i}" for "${this.locale}" locale. Falling back to ".other".`), "other"
}
throw new Error(`i18n: Plural form ".other" is required for "${this.locale}" locale`)
}
- selectPluralFormUsingFallbackRules(e) {
- e = Math.abs(Math.floor(e));
- const t = this.getPluralRulesForLocale();
- return t ? I18n.pluralRules[t](e) : "other"
+ selectPluralFormUsingFallbackRules(t) {
+ t = Math.abs(Math.floor(t));
+ const e = this.getPluralRulesForLocale();
+ return e ? I18n.pluralRules[e](t) : "other"
}
getPluralRulesForLocale() {
- const e = this.locale.split("-")[0];
- for (const t in I18n.pluralRulesMap) {
- const n = I18n.pluralRulesMap[t];
- if (n.includes(this.locale) || n.includes(e)) return t
+ const t = this.locale.split("-")[0];
+ for (const e in I18n.pluralRulesMap) {
+ const n = I18n.pluralRulesMap[e];
+ if (n.includes(this.locale) || n.includes(t)) return e
}
}
}
@@ -210,29 +210,29 @@ I18n.pluralRulesMap = {
spanish: ["pt-PT", "it", "es"],
welsh: ["cy"]
}, I18n.pluralRules = {
- arabic: e => 0 === e ? "zero" : 1 === e ? "one" : 2 === e ? "two" : e % 100 >= 3 && e % 100 <= 10 ? "few" : e % 100 >= 11 && e % 100 <= 99 ? "many" : "other",
+ arabic: t => 0 === t ? "zero" : 1 === t ? "one" : 2 === t ? "two" : t % 100 >= 3 && t % 100 <= 10 ? "few" : t % 100 >= 11 && t % 100 <= 99 ? "many" : "other",
chinese: () => "other",
- french: e => 0 === e || 1 === e ? "one" : "other",
- german: e => 1 === e ? "one" : "other",
- irish: e => 1 === e ? "one" : 2 === e ? "two" : e >= 3 && e <= 6 ? "few" : e >= 7 && e <= 10 ? "many" : "other",
- russian(e) {
- const t = e % 100,
- n = t % 10;
- return 1 === n && 11 !== t ? "one" : n >= 2 && n <= 4 && !(t >= 12 && t <= 14) ? "few" : 0 === n || n >= 5 && n <= 9 || t >= 11 && t <= 14 ? "many" : "other"
+ french: t => 0 === t || 1 === t ? "one" : "other",
+ german: t => 1 === t ? "one" : "other",
+ irish: t => 1 === t ? "one" : 2 === t ? "two" : t >= 3 && t <= 6 ? "few" : t >= 7 && t <= 10 ? "many" : "other",
+ russian(t) {
+ const e = t % 100,
+ n = e % 10;
+ return 1 === n && 11 !== e ? "one" : n >= 2 && n <= 4 && !(e >= 12 && e <= 14) ? "few" : 0 === n || n >= 5 && n <= 9 || e >= 11 && e <= 14 ? "many" : "other"
},
- scottish: e => 1 === e || 11 === e ? "one" : 2 === e || 12 === e ? "two" : e >= 3 && e <= 10 || e >= 13 && e <= 19 ? "few" : "other",
- spanish: e => 1 === e ? "one" : e % 1e6 == 0 && 0 !== e ? "many" : "other",
- welsh: e => 0 === e ? "zero" : 1 === e ? "one" : 2 === e ? "two" : 3 === e ? "few" : 6 === e ? "many" : "other"
+ scottish: t => 1 === t || 11 === t ? "one" : 2 === t || 12 === t ? "two" : t >= 3 && t <= 10 || t >= 13 && t <= 19 ? "few" : "other",
+ spanish: t => 1 === t ? "one" : t % 1e6 == 0 && 0 !== t ? "many" : "other",
+ welsh: t => 0 === t ? "zero" : 1 === t ? "one" : 2 === t ? "two" : 3 === t ? "few" : 6 === t ? "many" : "other"
};
class Accordion extends GOVUKFrontendComponent {
- constructor(e, t = {}) {
- if (super(e), this.$module = void 0, this.config = void 0, this.i18n = void 0, this.controlsClass = "govuk-accordion__controls", this.showAllClass = "govuk-accordion__show-all", this.showAllTextClass = "govuk-accordion__show-all-text", this.sectionClass = "govuk-accordion__section", this.sectionExpandedClass = "govuk-accordion__section--expanded", this.sectionButtonClass = "govuk-accordion__section-button", this.sectionHeaderClass = "govuk-accordion__section-header", this.sectionHeadingClass = "govuk-accordion__section-heading", this.sectionHeadingDividerClass = "govuk-accordion__section-heading-divider", this.sectionHeadingTextClass = "govuk-accordion__section-heading-text", this.sectionHeadingTextFocusClass = "govuk-accordion__section-heading-text-focus", this.sectionShowHideToggleClass = "govuk-accordion__section-toggle", this.sectionShowHideToggleFocusClass = "govuk-accordion__section-toggle-focus", this.sectionShowHideTextClass = "govuk-accordion__section-toggle-text", this.upChevronIconClass = "govuk-accordion-nav__chevron", this.downChevronIconClass = "govuk-accordion-nav__chevron--down", this.sectionSummaryClass = "govuk-accordion__section-summary", this.sectionSummaryFocusClass = "govuk-accordion__section-summary-focus", this.sectionContentClass = "govuk-accordion__section-content", this.$sections = void 0, this.$showAllButton = null, this.$showAllIcon = null, this.$showAllText = null, !(e instanceof HTMLElement)) throw new ElementError({
+ constructor(t, e = {}) {
+ if (super(t), this.$root = void 0, this.config = void 0, this.i18n = void 0, this.controlsClass = "govuk-accordion__controls", this.showAllClass = "govuk-accordion__show-all", this.showAllTextClass = "govuk-accordion__show-all-text", this.sectionClass = "govuk-accordion__section", this.sectionExpandedClass = "govuk-accordion__section--expanded", this.sectionButtonClass = "govuk-accordion__section-button", this.sectionHeaderClass = "govuk-accordion__section-header", this.sectionHeadingClass = "govuk-accordion__section-heading", this.sectionHeadingDividerClass = "govuk-accordion__section-heading-divider", this.sectionHeadingTextClass = "govuk-accordion__section-heading-text", this.sectionHeadingTextFocusClass = "govuk-accordion__section-heading-text-focus", this.sectionShowHideToggleClass = "govuk-accordion__section-toggle", this.sectionShowHideToggleFocusClass = "govuk-accordion__section-toggle-focus", this.sectionShowHideTextClass = "govuk-accordion__section-toggle-text", this.upChevronIconClass = "govuk-accordion-nav__chevron", this.downChevronIconClass = "govuk-accordion-nav__chevron--down", this.sectionSummaryClass = "govuk-accordion__section-summary", this.sectionSummaryFocusClass = "govuk-accordion__section-summary-focus", this.sectionContentClass = "govuk-accordion__section-content", this.$sections = void 0, this.$showAllButton = null, this.$showAllIcon = null, this.$showAllText = null, !(t instanceof HTMLElement)) throw new ElementError({
componentName: "Accordion",
- element: e,
- identifier: "Root element (`$module`)"
+ element: t,
+ identifier: "Root element (`$root`)"
});
- this.$module = e, this.config = mergeConfigs(Accordion.defaults, t, normaliseDataset(Accordion, e.dataset)), this.i18n = new I18n(this.config.i18n);
- const n = this.$module.querySelectorAll(`.${this.sectionClass}`);
+ this.$root = t, this.config = mergeConfigs(Accordion.defaults, e, normaliseDataset(Accordion, t.dataset)), this.i18n = new I18n(this.config.i18n);
+ const n = this.$root.querySelectorAll(`.${this.sectionClass}`);
if (!n.length) throw new ElementError({
componentName: "Accordion",
identifier: `Sections (\`<div class="${this.sectionClass}">\`)`
@@ -241,23 +241,23 @@ class Accordion extends GOVUKFrontendComponent {
}
initControls() {
this.$showAllButton = document.createElement("button"), this.$showAllButton.setAttribute("type", "button"), this.$showAllButton.setAttribute("class", this.showAllClass), this.$showAllButton.setAttribute("aria-expanded", "false"), this.$showAllIcon = document.createElement("span"), this.$showAllIcon.classList.add(this.upChevronIconClass), this.$showAllButton.appendChild(this.$showAllIcon);
- const e = document.createElement("div");
- e.setAttribute("class", this.controlsClass), e.appendChild(this.$showAllButton), this.$module.insertBefore(e, this.$module.firstChild), this.$showAllText = document.createElement("span"), this.$showAllText.classList.add(this.showAllTextClass), this.$showAllButton.appendChild(this.$showAllText), this.$showAllButton.addEventListener("click", (() => this.onShowOrHideAllToggle())), "onbeforematch" in document && document.addEventListener("beforematch", (e => this.onBeforeMatch(e)))
+ const t = document.createElement("div");
+ t.setAttribute("class", this.controlsClass), t.appendChild(this.$showAllButton), this.$root.insertBefore(t, this.$root.firstChild), this.$showAllText = document.createElement("span"), this.$showAllText.classList.add(this.showAllTextClass), this.$showAllButton.appendChild(this.$showAllText), this.$showAllButton.addEventListener("click", (() => this.onShowOrHideAllToggle())), "onbeforematch" in document && document.addEventListener("beforematch", (t => this.onBeforeMatch(t)))
}
initSectionHeaders() {
- this.$sections.forEach(((e, t) => {
- const n = e.querySelector(`.${this.sectionHeaderClass}`);
+ this.$sections.forEach(((t, e) => {
+ const n = t.querySelector(`.${this.sectionHeaderClass}`);
if (!n) throw new ElementError({
componentName: "Accordion",
identifier: `Section headers (\`<div class="${this.sectionHeaderClass}">\`)`
});
- this.constructHeaderMarkup(n, t), this.setExpanded(this.isExpanded(e), e), n.addEventListener("click", (() => this.onSectionToggle(e))), this.setInitialState(e)
+ this.constructHeaderMarkup(n, e), this.setExpanded(this.isExpanded(t), t), n.addEventListener("click", (() => this.onSectionToggle(t))), this.setInitialState(t)
}))
}
- constructHeaderMarkup(e, t) {
- const n = e.querySelector(`.${this.sectionButtonClass}`),
- i = e.querySelector(`.${this.sectionHeadingClass}`),
- s = e.querySelector(`.${this.sectionSummaryClass}`);
+ constructHeaderMarkup(t, e) {
+ const n = t.querySelector(`.${this.sectionButtonClass}`),
+ i = t.querySelector(`.${this.sectionHeadingClass}`),
+ o = t.querySelector(`.${this.sectionSummaryClass}`);
if (!i) throw new ElementError({
componentName: "Accordion",
identifier: `Section heading (\`.${this.sectionHeadingClass}\`)`
@@ -266,95 +266,95 @@ class Accordion extends GOVUKFrontendComponent {
componentName: "Accordion",
identifier: `Section button placeholder (\`<span class="${this.sectionButtonClass}">\`)`
});
- const o = document.createElement("button");
- o.setAttribute("type", "button"), o.setAttribute("aria-controls", `${this.$module.id}-content-${t+1}`);
- for (const d of Array.from(n.attributes)) "id" !== d.name && o.setAttribute(d.name, d.value);
+ const s = document.createElement("button");
+ s.setAttribute("type", "button"), s.setAttribute("aria-controls", `${this.$root.id}-content-${e+1}`);
+ for (const d of Array.from(n.attributes)) "id" !== d.name && s.setAttribute(d.name, d.value);
const r = document.createElement("span");
r.classList.add(this.sectionHeadingTextClass), r.id = n.id;
const a = document.createElement("span");
- a.classList.add(this.sectionHeadingTextFocusClass), r.appendChild(a), Array.from(n.childNodes).forEach((e => a.appendChild(e)));
- const l = document.createElement("span");
- l.classList.add(this.sectionShowHideToggleClass), l.setAttribute("data-nosnippet", "");
+ a.classList.add(this.sectionHeadingTextFocusClass), r.appendChild(a), Array.from(n.childNodes).forEach((t => a.appendChild(t)));
const c = document.createElement("span");
- c.classList.add(this.sectionShowHideToggleFocusClass), l.appendChild(c);
- const u = document.createElement("span"),
- h = document.createElement("span");
- if (h.classList.add(this.upChevronIconClass), c.appendChild(h), u.classList.add(this.sectionShowHideTextClass), c.appendChild(u), o.appendChild(r), o.appendChild(this.getButtonPunctuationEl()), s) {
- const e = document.createElement("span"),
- t = document.createElement("span");
- t.classList.add(this.sectionSummaryFocusClass), e.appendChild(t);
- for (const n of Array.from(s.attributes)) e.setAttribute(n.name, n.value);
- Array.from(s.childNodes).forEach((e => t.appendChild(e))), s.remove(), o.appendChild(e), o.appendChild(this.getButtonPunctuationEl())
+ c.classList.add(this.sectionShowHideToggleClass), c.setAttribute("data-nosnippet", "");
+ const l = document.createElement("span");
+ l.classList.add(this.sectionShowHideToggleFocusClass), c.appendChild(l);
+ const h = document.createElement("span"),
+ u = document.createElement("span");
+ if (u.classList.add(this.upChevronIconClass), l.appendChild(u), h.classList.add(this.sectionShowHideTextClass), l.appendChild(h), s.appendChild(r), s.appendChild(this.getButtonPunctuationEl()), o) {
+ const t = document.createElement("span"),
+ e = document.createElement("span");
+ e.classList.add(this.sectionSummaryFocusClass), t.appendChild(e);
+ for (const n of Array.from(o.attributes)) t.setAttribute(n.name, n.value);
+ Array.from(o.childNodes).forEach((t => e.appendChild(t))), o.remove(), s.appendChild(t), s.appendChild(this.getButtonPunctuationEl())
}
- o.appendChild(l), i.removeChild(n), i.appendChild(o)
+ s.appendChild(c), i.removeChild(n), i.appendChild(s)
}
- onBeforeMatch(e) {
- const t = e.target;
- if (!(t instanceof Element)) return;
- const n = t.closest(`.${this.sectionClass}`);
+ onBeforeMatch(t) {
+ const e = t.target;
+ if (!(e instanceof Element)) return;
+ const n = e.closest(`.${this.sectionClass}`);
n && this.setExpanded(!0, n)
}
- onSectionToggle(e) {
- const t = !this.isExpanded(e);
- this.setExpanded(t, e), this.storeState(e, t)
+ onSectionToggle(t) {
+ const e = !this.isExpanded(t);
+ this.setExpanded(e, t), this.storeState(t, e)
}
onShowOrHideAllToggle() {
- const e = !this.areAllSectionsOpen();
- this.$sections.forEach((t => {
- this.setExpanded(e, t), this.storeState(t, e)
- })), this.updateShowAllButton(e)
- }
- setExpanded(e, t) {
- const n = t.querySelector(`.${this.upChevronIconClass}`),
- i = t.querySelector(`.${this.sectionShowHideTextClass}`),
- s = t.querySelector(`.${this.sectionButtonClass}`),
- o = t.querySelector(`.${this.sectionContentClass}`);
- if (!o) throw new ElementError({
+ const t = !this.areAllSectionsOpen();
+ this.$sections.forEach((e => {
+ this.setExpanded(t, e), this.storeState(e, t)
+ })), this.updateShowAllButton(t)
+ }
+ setExpanded(t, e) {
+ const n = e.querySelector(`.${this.upChevronIconClass}`),
+ i = e.querySelector(`.${this.sectionShowHideTextClass}`),
+ o = e.querySelector(`.${this.sectionButtonClass}`),
+ s = e.querySelector(`.${this.sectionContentClass}`);
+ if (!s) throw new ElementError({
componentName: "Accordion",
identifier: `Section content (\`<div class="${this.sectionContentClass}">\`)`
});
- if (!n || !i || !s) return;
- const r = e ? this.i18n.t("hideSection") : this.i18n.t("showSection");
- i.textContent = r, s.setAttribute("aria-expanded", `${e}`);
+ if (!n || !i || !o) return;
+ const r = t ? this.i18n.t("hideSection") : this.i18n.t("showSection");
+ i.textContent = r, o.setAttribute("aria-expanded", `${t}`);
const a = [],
- l = t.querySelector(`.${this.sectionHeadingTextClass}`);
- l && a.push(`${l.textContent}`.trim());
- const c = t.querySelector(`.${this.sectionSummaryClass}`);
+ c = e.querySelector(`.${this.sectionHeadingTextClass}`);
c && a.push(`${c.textContent}`.trim());
- const u = e ? this.i18n.t("hideSectionAriaLabel") : this.i18n.t("showSectionAriaLabel");
- a.push(u), s.setAttribute("aria-label", a.join(" , ")), e ? (o.removeAttribute("hidden"), t.classList.add(this.sectionExpandedClass), n.classList.remove(this.downChevronIconClass)) : (o.setAttribute("hidden", "until-found"), t.classList.remove(this.sectionExpandedClass), n.classList.add(this.downChevronIconClass)), this.updateShowAllButton(this.areAllSectionsOpen())
+ const l = e.querySelector(`.${this.sectionSummaryClass}`);
+ l && a.push(`${l.textContent}`.trim());
+ const h = t ? this.i18n.t("hideSectionAriaLabel") : this.i18n.t("showSectionAriaLabel");
+ a.push(h), o.setAttribute("aria-label", a.join(" , ")), t ? (s.removeAttribute("hidden"), e.classList.add(this.sectionExpandedClass), n.classList.remove(this.downChevronIconClass)) : (s.setAttribute("hidden", "until-found"), e.classList.remove(this.sectionExpandedClass), n.classList.add(this.downChevronIconClass)), this.updateShowAllButton(this.areAllSectionsOpen())
}
- isExpanded(e) {
- return e.classList.contains(this.sectionExpandedClass)
+ isExpanded(t) {
+ return t.classList.contains(this.sectionExpandedClass)
}
areAllSectionsOpen() {
- return Array.from(this.$sections).every((e => this.isExpanded(e)))
+ return Array.from(this.$sections).every((t => this.isExpanded(t)))
}
- updateShowAllButton(e) {
- this.$showAllButton && this.$showAllText && this.$showAllIcon && (this.$showAllButton.setAttribute("aria-expanded", e.toString()), this.$showAllText.textContent = e ? this.i18n.t("hideAllSections") : this.i18n.t("showAllSections"), this.$showAllIcon.classList.toggle(this.downChevronIconClass, !e))
+ updateShowAllButton(t) {
+ this.$showAllButton && this.$showAllText && this.$showAllIcon && (this.$showAllButton.setAttribute("aria-expanded", t.toString()), this.$showAllText.textContent = t ? this.i18n.t("hideAllSections") : this.i18n.t("showAllSections"), this.$showAllIcon.classList.toggle(this.downChevronIconClass, !t))
}
- getIdentifier(e) {
- const t = e.querySelector(`.${this.sectionButtonClass}`);
- return null == t ? void 0 : t.getAttribute("aria-controls")
+ getIdentifier(t) {
+ const e = t.querySelector(`.${this.sectionButtonClass}`);
+ return null == e ? void 0 : e.getAttribute("aria-controls")
}
- storeState(e, t) {
+ storeState(t, e) {
if (!this.config.rememberExpanded) return;
- const n = this.getIdentifier(e);
+ const n = this.getIdentifier(t);
if (n) try {
- window.sessionStorage.setItem(n, t.toString())
+ window.sessionStorage.setItem(n, e.toString())
} catch (i) {}
}
- setInitialState(e) {
+ setInitialState(t) {
if (!this.config.rememberExpanded) return;
- const t = this.getIdentifier(e);
- if (t) try {
- const n = window.sessionStorage.getItem(t);
- null !== n && this.setExpanded("true" === n, e)
+ const e = this.getIdentifier(t);
+ if (e) try {
+ const n = window.sessionStorage.getItem(e);
+ null !== n && this.setExpanded("true" === n, t)
} catch (n) {}
}
getButtonPunctuationEl() {
- const e = document.createElement("span");
- return e.classList.add("govuk-visually-hidden", this.sectionHeadingDividerClass), e.textContent = ", ", e
+ const t = document.createElement("span");
+ return t.classList.add("govuk-visually-hidden", this.sectionHeadingDividerClass), t.textContent = ", ", t
}
}
Accordion.moduleName = "govuk-accordion", Accordion.defaults = Object.freeze({
@@ -378,28 +378,28 @@ Accordion.moduleName = "govuk-accordion", Accordion.defaults = Object.freeze({
}
});
class Button extends GOVUKFrontendComponent {
- constructor(e, t = {}) {
- if (super(e), this.$module = void 0, this.config = void 0, this.debounceFormSubmitTimer = null, !(e instanceof HTMLElement)) throw new ElementError({
+ constructor(t, e = {}) {
+ if (super(t), this.$root = void 0, this.config = void 0, this.debounceFormSubmitTimer = null, !(t instanceof HTMLElement)) throw new ElementError({
componentName: "Button",
- element: e,
- identifier: "Root element (`$module`)"
+ element: t,
+ identifier: "Root element (`$root`)"
});
- this.$module = e, this.config = mergeConfigs(Button.defaults, t, normaliseDataset(Button, e.dataset)), this.$module.addEventListener("keydown", (e => this.handleKeyDown(e))), this.$module.addEventListener("click", (e => this.debounce(e)))
+ this.$root = t, this.config = mergeConfigs(Button.defaults, e, normaliseDataset(Button, t.dataset)), this.$root.addEventListener("keydown", (t => this.handleKeyDown(t))), this.$root.addEventListener("click", (t => this.debounce(t)))
}
- handleKeyDown(e) {
- const t = e.target;
- " " === e.key && t instanceof HTMLElement && "button" === t.getAttribute("role") && (e.preventDefault(), t.click())
+ handleKeyDown(t) {
+ const e = t.target;
+ " " === t.key && e instanceof HTMLElement && "button" === e.getAttribute("role") && (t.preventDefault(), e.click())
}
- debounce(e) {
- if (this.config.preventDoubleClick) return this.debounceFormSubmitTimer ? (e.preventDefault(), !1) : void(this.debounceFormSubmitTimer = window.setTimeout((() => {
+ debounce(t) {
+ if (this.config.preventDoubleClick) return this.debounceFormSubmitTimer ? (t.preventDefault(), !1) : void(this.debounceFormSubmitTimer = window.setTimeout((() => {
this.debounceFormSubmitTimer = null
}), 1e3))
}
}
-function closestAttributeValue(e, t) {
- const n = e.closest(`[${t}]`);
- return n ? n.getAttribute(t) : null
+function closestAttributeValue(t, e) {
+ const n = t.closest(`[${e}]`);
+ return n ? n.getAttribute(e) : null
}
Button.moduleName = "govuk-button", Button.defaults = Object.freeze({
preventDoubleClick: !1
@@ -411,59 +411,59 @@ Button.moduleName = "govuk-button", Button.defaults = Object.freeze({
}
});
class CharacterCount extends GOVUKFrontendComponent {
- constructor(e, t = {}) {
+ constructor(t, e = {}) {
var n, i;
- if (super(e), this.$module = void 0, this.$textarea = void 0, this.$visibleCountMessage = void 0, this.$screenReaderCountMessage = void 0, this.lastInputTimestamp = null, this.lastInputValue = "", this.valueChecker = null, this.config = void 0, this.i18n = void 0, this.maxLength = void 0, !(e instanceof HTMLElement)) throw new ElementError({
+ if (super(t), this.$root = void 0, this.$textarea = void 0, this.$visibleCountMessage = void 0, this.$screenReaderCountMessage = void 0, this.lastInputTimestamp = null, this.lastInputValue = "", this.valueChecker = null, this.config = void 0, this.i18n = void 0, this.maxLength = void 0, !(t instanceof HTMLElement)) throw new ElementError({
componentName: "Character count",
- element: e,
- identifier: "Root element (`$module`)"
+ element: t,
+ identifier: "Root element (`$root`)"
});
- const s = e.querySelector(".govuk-js-character-count");
- if (!(s instanceof HTMLTextAreaElement || s instanceof HTMLInputElement)) throw new ElementError({
+ const o = t.querySelector(".govuk-js-character-count");
+ if (!(o instanceof HTMLTextAreaElement || o instanceof HTMLInputElement)) throw new ElementError({
componentName: "Character count",
- element: s,
+ element: o,
expectedType: "HTMLTextareaElement or HTMLInputElement",
identifier: "Form field (`.govuk-js-character-count`)"
});
- const o = normaliseDataset(CharacterCount, e.dataset);
+ const s = normaliseDataset(CharacterCount, t.dataset);
let r = {};
- ("maxwords" in o || "maxlength" in o) && (r = {
+ ("maxwords" in s || "maxlength" in s) && (r = {
maxlength: void 0,
maxwords: void 0
- }), this.config = mergeConfigs(CharacterCount.defaults, t, r, o);
- const a = function(e, t) {
+ }), this.config = mergeConfigs(CharacterCount.defaults, e, r, s);
+ const a = function(t, e) {
const n = [];
- for (const [i, s] of Object.entries(e)) {
- const e = [];
- if (Array.isArray(s)) {
+ for (const [i, o] of Object.entries(t)) {
+ const t = [];
+ if (Array.isArray(o)) {
for (const {
required: n,
errorMessage: i
}
- of s) n.every((e => !!t[e])) || e.push(i);
- "anyOf" !== i || s.length - e.length >= 1 || n.push(...e)
+ of o) n.every((t => !!e[t])) || t.push(i);
+ "anyOf" !== i || o.length - t.length >= 1 || n.push(...t)
}
}
return n
}(CharacterCount.schema, this.config);
if (a[0]) throw new ConfigError(`Character count: ${a[0]}`);
this.i18n = new I18n(this.config.i18n, {
- locale: closestAttributeValue(e, "lang")
- }), this.maxLength = null != (n = null != (i = this.config.maxwords) ? i : this.config.maxlength) ? n : 1 / 0, this.$module = e, this.$textarea = s;
- const l = `${this.$textarea.id}-info`,
- c = document.getElementById(l);
- if (!c) throw new ElementError({
+ locale: closestAttributeValue(t, "lang")
+ }), this.maxLength = null != (n = null != (i = this.config.maxwords) ? i : this.config.maxlength) ? n : 1 / 0, this.$root = t, this.$textarea = o;
+ const c = `${this.$textarea.id}-info`,
+ l = document.getElementById(c);
+ if (!l) throw new ElementError({
componentName: "Character count",
- element: c,
- identifier: `Count message (\`id="${l}"\`)`
+ element: l,
+ identifier: `Count message (\`id="${c}"\`)`
});
- `${c.textContent}`.match(/^\s*$/) && (c.textContent = this.i18n.t("textareaDescription", {
+ `${l.textContent}`.match(/^\s*$/) && (l.textContent = this.i18n.t("textareaDescription", {
count: this.maxLength
- })), this.$textarea.insertAdjacentElement("afterend", c);
- const u = document.createElement("div");
- u.className = "govuk-character-count__sr-status govuk-visually-hidden", u.setAttribute("aria-live", "polite"), this.$screenReaderCountMessage = u, c.insertAdjacentElement("afterend", u);
+ })), this.$textarea.insertAdjacentElement("afterend", l);
const h = document.createElement("div");
- h.className = c.className, h.classList.add("govuk-character-count__status"), h.setAttribute("aria-hidden", "true"), this.$visibleCountMessage = h, c.insertAdjacentElement("afterend", h), c.classList.add("govuk-visually-hidden"), this.$textarea.removeAttribute("maxlength"), this.bindChangeEvents(), window.addEventListener("pageshow", (() => this.updateCountMessage())), this.updateCountMessage()
+ h.className = "govuk-character-count__sr-status govuk-visually-hidden", h.setAttribute("aria-live", "polite"), this.$screenReaderCountMessage = h, l.insertAdjacentElement("afterend", h);
+ const u = document.createElement("div");
+ u.className = l.className, u.classList.add("govuk-character-count__status"), u.setAttribute("aria-hidden", "true"), this.$visibleCountMessage = u, l.insertAdjacentElement("afterend", u), l.classList.add("govuk-visually-hidden"), this.$textarea.removeAttribute("maxlength"), this.bindChangeEvents(), window.addEventListener("pageshow", (() => this.updateCountMessage())), this.updateCountMessage()
}
bindChangeEvents() {
this.$textarea.addEventListener("keyup", (() => this.handleKeyUp())), this.$textarea.addEventListener("focus", (() => this.handleFocus())), this.$textarea.addEventListener("blur", (() => this.handleBlur()))
@@ -486,35 +486,35 @@ class CharacterCount extends GOVUKFrontendComponent {
this.updateVisibleCountMessage(), this.updateScreenReaderCountMessage()
}
updateVisibleCountMessage() {
- const e = this.maxLength - this.count(this.$textarea.value) < 0;
- this.$visibleCountMessage.classList.toggle("govuk-character-count__message--disabled", !this.isOverThreshold()), this.$textarea.classList.toggle("govuk-textarea--error", e), this.$visibleCountMessage.classList.toggle("govuk-error-message", e), this.$visibleCountMessage.classList.toggle("govuk-hint", !e), this.$visibleCountMessage.textContent = this.getCountMessage()
+ const t = this.maxLength - this.count(this.$textarea.value) < 0;
+ this.$visibleCountMessage.classList.toggle("govuk-character-count__message--disabled", !this.isOverThreshold()), this.$textarea.classList.toggle("govuk-textarea--error", t), this.$visibleCountMessage.classList.toggle("govuk-error-message", t), this.$visibleCountMessage.classList.toggle("govuk-hint", !t), this.$visibleCountMessage.textContent = this.getCountMessage()
}
updateScreenReaderCountMessage() {
this.isOverThreshold() ? this.$screenReaderCountMessage.removeAttribute("aria-hidden") : this.$screenReaderCountMessage.setAttribute("aria-hidden", "true"), this.$screenReaderCountMessage.textContent = this.getCountMessage()
}
- count(e) {
+ count(t) {
if (this.config.maxwords) {
- var t;
- return (null != (t = e.match(/\S+/g)) ? t : []).length
+ var e;
+ return (null != (e = t.match(/\S+/g)) ? e : []).length
}
- return e.length
+ return t.length
}
getCountMessage() {
- const e = this.maxLength - this.count(this.$textarea.value),
- t = this.config.maxwords ? "words" : "characters";
- return this.formatCountMessage(e, t)
- }
- formatCountMessage(e, t) {
- if (0 === e) return this.i18n.t(`${t}AtLimit`);
- const n = e < 0 ? "OverLimit" : "UnderLimit";
- return this.i18n.t(`${t}${n}`, {
- count: Math.abs(e)
+ const t = this.maxLength - this.count(this.$textarea.value),
+ e = this.config.maxwords ? "words" : "characters";
+ return this.formatCountMessage(t, e)
+ }
+ formatCountMessage(t, e) {
+ if (0 === t) return this.i18n.t(`${e}AtLimit`);
+ const n = t < 0 ? "OverLimit" : "UnderLimit";
+ return this.i18n.t(`${e}${n}`, {
+ count: Math.abs(t)
})
}
isOverThreshold() {
if (!this.config.threshold) return !0;
- const e = this.count(this.$textarea.value);
- return this.maxLength * this.config.threshold / 100 <= e
+ const t = this.count(this.$textarea.value);
+ return this.maxLength * this.config.threshold / 100 <= t
}
}
CharacterCount.moduleName = "govuk-character-count", CharacterCount.defaults = Object.freeze({
@@ -566,98 +566,98 @@ CharacterCount.moduleName = "govuk-character-count", CharacterCount.defaults = O
}]
});
class Checkboxes extends GOVUKFrontendComponent {
- constructor(e) {
- if (super(e), this.$module = void 0, this.$inputs = void 0, !(e instanceof HTMLElement)) throw new ElementError({
+ constructor(t) {
+ if (super(t), this.$root = void 0, this.$inputs = void 0, !(t instanceof HTMLElement)) throw new ElementError({
componentName: "Checkboxes",
- element: e,
- identifier: "Root element (`$module`)"
+ element: t,
+ identifier: "Root element (`$root`)"
});
- const t = e.querySelectorAll('input[type="checkbox"]');
- if (!t.length) throw new ElementError({
+ const e = t.querySelectorAll('input[type="checkbox"]');
+ if (!e.length) throw new ElementError({
componentName: "Checkboxes",
identifier: 'Form inputs (`<input type="checkbox">`)'
});
- this.$module = e, this.$inputs = t, this.$inputs.forEach((e => {
- const t = e.getAttribute("data-aria-controls");
- if (t) {
- if (!document.getElementById(t)) throw new ElementError({
+ this.$root = t, this.$inputs = e, this.$inputs.forEach((t => {
+ const e = t.getAttribute("data-aria-controls");
+ if (e) {
+ if (!document.getElementById(e)) throw new ElementError({
componentName: "Checkboxes",
- identifier: `Conditional reveal (\`id="${t}"\`)`
+ identifier: `Conditional reveal (\`id="${e}"\`)`
});
- e.setAttribute("aria-controls", t), e.removeAttribute("data-aria-controls")
+ t.setAttribute("aria-controls", e), t.removeAttribute("data-aria-controls")
}
- })), window.addEventListener("pageshow", (() => this.syncAllConditionalReveals())), this.syncAllConditionalReveals(), this.$module.addEventListener("click", (e => this.handleClick(e)))
+ })), window.addEventListener("pageshow", (() => this.syncAllConditionalReveals())), this.syncAllConditionalReveals(), this.$root.addEventListener("click", (t => this.handleClick(t)))
}
syncAllConditionalReveals() {
- this.$inputs.forEach((e => this.syncConditionalRevealWithInputState(e)))
+ this.$inputs.forEach((t => this.syncConditionalRevealWithInputState(t)))
}
- syncConditionalRevealWithInputState(e) {
- const t = e.getAttribute("aria-controls");
- if (!t) return;
- const n = document.getElementById(t);
+ syncConditionalRevealWithInputState(t) {
+ const e = t.getAttribute("aria-controls");
+ if (!e) return;
+ const n = document.getElementById(e);
if (null != n && n.classList.contains("govuk-checkboxes__conditional")) {
- const t = e.checked;
- e.setAttribute("aria-expanded", t.toString()), n.classList.toggle("govuk-checkboxes__conditional--hidden", !t)
+ const e = t.checked;
+ t.setAttribute("aria-expanded", e.toString()), n.classList.toggle("govuk-checkboxes__conditional--hidden", !e)
}
}
- unCheckAllInputsExcept(e) {
- document.querySelectorAll(`input[type="checkbox"][name="${e.name}"]`).forEach((t => {
- e.form === t.form && t !== e && (t.checked = !1, this.syncConditionalRevealWithInputState(t))
+ unCheckAllInputsExcept(t) {
+ document.querySelectorAll(`input[type="checkbox"][name="${t.name}"]`).forEach((e => {
+ t.form === e.form && e !== t && (e.checked = !1, this.syncConditionalRevealWithInputState(e))
}))
}
- unCheckExclusiveInputs(e) {
- document.querySelectorAll(`input[data-behaviour="exclusive"][type="checkbox"][name="${e.name}"]`).forEach((t => {
- e.form === t.form && (t.checked = !1, this.syncConditionalRevealWithInputState(t))
+ unCheckExclusiveInputs(t) {
+ document.querySelectorAll(`input[data-behaviour="exclusive"][type="checkbox"][name="${t.name}"]`).forEach((e => {
+ t.form === e.form && (e.checked = !1, this.syncConditionalRevealWithInputState(e))
}))
}
- handleClick(e) {
- const t = e.target;
- if (!(t instanceof HTMLInputElement) || "checkbox" !== t.type) return;
- if (t.getAttribute("aria-controls") && this.syncConditionalRevealWithInputState(t), !t.checked) return;
- "exclusive" === t.getAttribute("data-behaviour") ? this.unCheckAllInputsExcept(t) : this.unCheckExclusiveInputs(t)
+ handleClick(t) {
+ const e = t.target;
+ if (!(e instanceof HTMLInputElement) || "checkbox" !== e.type) return;
+ if (e.getAttribute("aria-controls") && this.syncConditionalRevealWithInputState(e), !e.checked) return;
+ "exclusive" === e.getAttribute("data-behaviour") ? this.unCheckAllInputsExcept(e) : this.unCheckExclusiveInputs(e)
}
}
Checkboxes.moduleName = "govuk-checkboxes";
class ErrorSummary extends GOVUKFrontendComponent {
- constructor(e, t = {}) {
- if (super(e), this.$module = void 0, this.config = void 0, !(e instanceof HTMLElement)) throw new ElementError({
+ constructor(t, e = {}) {
+ if (super(t), this.$root = void 0, this.config = void 0, !(t instanceof HTMLElement)) throw new ElementError({
componentName: "Error summary",
- element: e,
- identifier: "Root element (`$module`)"
+ element: t,
+ identifier: "Root element (`$root`)"
});
- this.$module = e, this.config = mergeConfigs(ErrorSummary.defaults, t, normaliseDataset(ErrorSummary, e.dataset)), this.config.disableAutoFocus || setFocus(this.$module), this.$module.addEventListener("click", (e => this.handleClick(e)))
+ this.$root = t, this.config = mergeConfigs(ErrorSummary.defaults, e, normaliseDataset(ErrorSummary, t.dataset)), this.config.disableAutoFocus || setFocus(this.$root), this.$root.addEventListener("click", (t => this.handleClick(t)))
}
- handleClick(e) {
- const t = e.target;
- t && this.focusTarget(t) && e.preventDefault()
+ handleClick(t) {
+ const e = t.target;
+ e && this.focusTarget(e) && t.preventDefault()
}
- focusTarget(e) {
- if (!(e instanceof HTMLAnchorElement)) return !1;
- const t = getFragmentFromUrl(e.href);
- if (!t) return !1;
- const n = document.getElementById(t);
+ focusTarget(t) {
+ if (!(t instanceof HTMLAnchorElement)) return !1;
+ const e = getFragmentFromUrl(t.href);
+ if (!e) return !1;
+ const n = document.getElementById(e);
if (!n) return !1;
const i = this.getAssociatedLegendOrLabel(n);
return !!i && (i.scrollIntoView(), n.focus({
preventScroll: !0
}), !0)
}
- getAssociatedLegendOrLabel(e) {
- var t;
- const n = e.closest("fieldset");
+ getAssociatedLegendOrLabel(t) {
+ var e;
+ const n = t.closest("fieldset");
if (n) {
- const t = n.getElementsByTagName("legend");
- if (t.length) {
- const n = t[0];
- if (e instanceof HTMLInputElement && ("checkbox" === e.type || "radio" === e.type)) return n;
+ const e = n.getElementsByTagName("legend");
+ if (e.length) {
+ const n = e[0];
+ if (t instanceof HTMLInputElement && ("checkbox" === t.type || "radio" === t.type)) return n;
const i = n.getBoundingClientRect().top,
- s = e.getBoundingClientRect();
- if (s.height && window.innerHeight) {
- if (s.top + s.height - i < window.innerHeight / 2) return n
+ o = t.getBoundingClientRect();
+ if (o.height && window.innerHeight) {
+ if (o.top + o.height - i < window.innerHeight / 2) return n
}
}
}
- return null != (t = document.querySelector(`label[for='${e.getAttribute("id")}']`)) ? t : e.closest("label")
+ return null != (e = document.querySelector(`label[for='${t.getAttribute("id")}']`)) ? e : t.closest("label")
}
}
ErrorSummary.moduleName = "govuk-error-summary", ErrorSummary.defaults = Object.freeze({
@@ -670,52 +670,52 @@ ErrorSummary.moduleName = "govuk-error-summary", ErrorSummary.defaults = Object.
}
});
class ExitThisPage extends GOVUKFrontendComponent {
- constructor(e, t = {}) {
- if (super(e), this.$module = void 0, this.config = void 0, this.i18n = void 0, this.$button = void 0, this.$skiplinkButton = null, this.$updateSpan = null, this.$indicatorContainer = null, this.$overlay = null, this.keypressCounter = 0, this.lastKeyWasModified = !1, this.timeoutTime = 5e3, this.keypressTimeoutId = null, this.timeoutMessageId = null, !(e instanceof HTMLElement)) throw new ElementError({
+ constructor(t, e = {}) {
+ if (super(t), this.$root = void 0, this.config = void 0, this.i18n = void 0, this.$button = void 0, this.$skiplinkButton = null, this.$updateSpan = null, this.$indicatorContainer = null, this.$overlay = null, this.keypressCounter = 0, this.lastKeyWasModified = !1, this.timeoutTime = 5e3, this.keypressTimeoutId = null, this.timeoutMessageId = null, !(t instanceof HTMLElement)) throw new ElementError({
componentName: "Exit this page",
- element: e,
- identifier: "Root element (`$module`)"
+ element: t,
+ identifier: "Root element (`$root`)"
});
- const n = e.querySelector(".govuk-exit-this-page__button");
+ const n = t.querySelector(".govuk-exit-this-page__button");
if (!(n instanceof HTMLAnchorElement)) throw new ElementError({
componentName: "Exit this page",
element: n,
expectedType: "HTMLAnchorElement",
identifier: "Button (`.govuk-exit-this-page__button`)"
});
- this.config = mergeConfigs(ExitThisPage.defaults, t, normaliseDataset(ExitThisPage, e.dataset)), this.i18n = new I18n(this.config.i18n), this.$module = e, this.$button = n;
+ this.config = mergeConfigs(ExitThisPage.defaults, e, normaliseDataset(ExitThisPage, t.dataset)), this.i18n = new I18n(this.config.i18n), this.$root = t, this.$button = n;
const i = document.querySelector(".govuk-js-exit-this-page-skiplink");
i instanceof HTMLAnchorElement && (this.$skiplinkButton = i), this.buildIndicator(), this.initUpdateSpan(), this.initButtonClickHandler(), "govukFrontendExitThisPageKeypress" in document.body.dataset || (document.addEventListener("keyup", this.handleKeypress.bind(this), !0), document.body.dataset.govukFrontendExitThisPageKeypress = "true"), window.addEventListener("pageshow", this.resetPage.bind(this))
}
initUpdateSpan() {
- this.$updateSpan = document.createElement("span"), this.$updateSpan.setAttribute("role", "status"), this.$updateSpan.className = "govuk-visually-hidden", this.$module.appendChild(this.$updateSpan)
+ this.$updateSpan = document.createElement("span"), this.$updateSpan.setAttribute("role", "status"), this.$updateSpan.className = "govuk-visually-hidden", this.$root.appendChild(this.$updateSpan)
}
initButtonClickHandler() {
this.$button.addEventListener("click", this.handleClick.bind(this)), this.$skiplinkButton && this.$skiplinkButton.addEventListener("click", this.handleClick.bind(this))
}
buildIndicator() {
this.$indicatorContainer = document.createElement("div"), this.$indicatorContainer.className = "govuk-exit-this-page__indicator", this.$indicatorContainer.setAttribute("aria-hidden", "true");
- for (let e = 0; e < 3; e++) {
- const e = document.createElement("div");
- e.className = "govuk-exit-this-page__indicator-light", this.$indicatorContainer.appendChild(e)
+ for (let t = 0; t < 3; t++) {
+ const t = document.createElement("div");
+ t.className = "govuk-exit-this-page__indicator-light", this.$indicatorContainer.appendChild(t)
}
this.$button.appendChild(this.$indicatorContainer)
}
updateIndicator() {
if (!this.$indicatorContainer) return;
this.$indicatorContainer.classList.toggle("govuk-exit-this-page__indicator--visible", this.keypressCounter > 0);
- this.$indicatorContainer.querySelectorAll(".govuk-exit-this-page__indicator-light").forEach(((e, t) => {
- e.classList.toggle("govuk-exit-this-page__indicator-light--on", t < this.keypressCounter)
+ this.$indicatorContainer.querySelectorAll(".govuk-exit-this-page__indicator-light").forEach(((t, e) => {
+ t.classList.toggle("govuk-exit-this-page__indicator-light--on", e < this.keypressCounter)
}))
}
exitPage() {
this.$updateSpan && (this.$updateSpan.textContent = "", document.body.classList.add("govuk-exit-this-page-hide-content"), this.$overlay = document.createElement("div"), this.$overlay.className = "govuk-exit-this-page-overlay", this.$overlay.setAttribute("role", "alert"), document.body.appendChild(this.$overlay), this.$overlay.textContent = this.i18n.t("activated"), window.location.href = this.$button.href)
}
- handleClick(e) {
- e.preventDefault(), this.exitPage()
+ handleClick(t) {
+ t.preventDefault(), this.exitPage()
}
- handleKeypress(e) {
- this.$updateSpan && ("Shift" !== e.key || this.lastKeyWasModified ? this.keypressTimeoutId && this.resetKeypressTimer() : (this.keypressCounter += 1, this.updateIndicator(), this.timeoutMessageId && (window.clearTimeout(this.timeoutMessageId), this.timeoutMessageId = null), this.keypressCounter >= 3 ? (this.keypressCounter = 0, this.keypressTimeoutId && (window.clearTimeout(this.keypressTimeoutId), this.keypressTimeoutId = null), this.exitPage()) : 1 === this.keypressCounter ? this.$updateSpan.textContent = this.i18n.t("pressTwoMoreTimes") : this.$updateSpan.textContent = this.i18n.t("pressOneMoreTime"), this.setKeypressTimer()), this.lastKeyWasModified = e.shiftKey)
+ handleKeypress(t) {
+ this.$updateSpan && ("Shift" !== t.key || this.lastKeyWasModified ? this.keypressTimeoutId && this.resetKeypressTimer() : (this.keypressCounter += 1, this.updateIndicator(), this.timeoutMessageId && (window.clearTimeout(this.timeoutMessageId), this.timeoutMessageId = null), this.keypressCounter >= 3 ? (this.keypressCounter = 0, this.keypressTimeoutId && (window.clearTimeout(this.keypressTimeoutId), this.keypressTimeoutId = null), this.exitPage()) : 1 === this.keypressCounter ? this.$updateSpan.textContent = this.i18n.t("pressTwoMoreTimes") : this.$updateSpan.textContent = this.i18n.t("pressOneMoreTime"), this.setKeypressTimer()), this.lastKeyWasModified = t.shiftKey)
}
setKeypressTimer() {
this.keypressTimeoutId && window.clearTimeout(this.keypressTimeoutId), this.keypressTimeoutId = window.setTimeout(this.resetKeypressTimer.bind(this), this.timeoutTime)
@@ -723,9 +723,9 @@ class ExitThisPage extends GOVUKFrontendComponent {
resetKeypressTimer() {
if (!this.$updateSpan) return;
this.keypressTimeoutId && (window.clearTimeout(this.keypressTimeoutId), this.keypressTimeoutId = null);
- const e = this.$updateSpan;
- this.keypressCounter = 0, e.textContent = this.i18n.t("timedOut"), this.timeoutMessageId = window.setTimeout((() => {
- e.textContent = ""
+ const t = this.$updateSpan;
+ this.keypressCounter = 0, t.textContent = this.i18n.t("timedOut"), this.timeoutMessageId = window.setTimeout((() => {
+ t.textContent = ""
}), this.timeoutTime), this.updateIndicator()
}
resetPage() {
@@ -747,16 +747,16 @@ ExitThisPage.moduleName = "govuk-exit-this-page", ExitThisPage.defaults = Object
}
});
class Header extends GOVUKFrontendComponent {
- constructor(e) {
- if (super(e), this.$module = void 0, this.$menuButton = void 0, this.$menu = void 0, this.menuIsOpen = !1, this.mql = null, !e) throw new ElementError({
+ constructor(t) {
+ if (super(t), this.$root = void 0, this.$menuButton = void 0, this.$menu = void 0, this.menuIsOpen = !1, this.mql = null, !t) throw new ElementError({
componentName: "Header",
- element: e,
- identifier: "Root element (`$module`)"
+ element: t,
+ identifier: "Root element (`$root`)"
});
- this.$module = e;
- const t = e.querySelector(".govuk-js-header-toggle");
- if (!t) return this;
- const n = t.getAttribute("aria-controls");
+ this.$root = t;
+ const e = t.querySelector(".govuk-js-header-toggle");
+ if (!e) return this;
+ const n = e.getAttribute("aria-controls");
if (!n) throw new ElementError({
componentName: "Header",
identifier: 'Navigation button (`<button class="govuk-js-header-toggle">`) attribute (`aria-controls`)'
@@ -767,15 +767,15 @@ class Header extends GOVUKFrontendComponent {
element: i,
identifier: `Navigation (\`<ul id="${n}">\`)`
});
- this.$menu = i, this.$menuButton = t, this.setupResponsiveChecks(), this.$menuButton.addEventListener("click", (() => this.handleMenuButtonClick()))
+ this.$menu = i, this.$menuButton = e, this.setupResponsiveChecks(), this.$menuButton.addEventListener("click", (() => this.handleMenuButtonClick()))
}
setupResponsiveChecks() {
- const e = getBreakpoint("desktop");
- if (!e.value) throw new ElementError({
+ const t = getBreakpoint("desktop");
+ if (!t.value) throw new ElementError({
componentName: "Header",
- identifier: `CSS custom property (\`${e.property}\`) on pseudo-class \`:root\``
+ identifier: `CSS custom property (\`${t.property}\`) on pseudo-class \`:root\``
});
- this.mql = window.matchMedia(`(min-width: ${e.value})`), "addEventListener" in this.mql ? this.mql.addEventListener("change", (() => this.checkMode())) : this.mql.addListener((() => this.checkMode())), this.checkMode()
+ this.mql = window.matchMedia(`(min-width: ${t.value})`), "addEventListener" in this.mql ? this.mql.addEventListener("change", (() => this.checkMode())) : this.mql.addListener((() => this.checkMode())), this.checkMode()
}
checkMode() {
this.mql && this.$menu && this.$menuButton && (this.mql.matches ? (this.$menu.removeAttribute("hidden"), this.$menuButton.setAttribute("hidden", "")) : (this.$menuButton.removeAttribute("hidden"), this.$menuButton.setAttribute("aria-expanded", this.menuIsOpen.toString()), this.menuIsOpen ? this.$menu.removeAttribute("hidden") : this.$menu.setAttribute("hidden", "")))
@@ -786,13 +786,13 @@ class Header extends GOVUKFrontendComponent {
}
Header.moduleName = "govuk-header";
class NotificationBanner extends GOVUKFrontendComponent {
- constructor(e, t = {}) {
- if (super(e), this.$module = void 0, this.config = void 0, !(e instanceof HTMLElement)) throw new ElementError({
+ constructor(t, e = {}) {
+ if (super(t), this.$root = void 0, this.config = void 0, !(t instanceof HTMLElement)) throw new ElementError({
componentName: "Notification banner",
- element: e,
- identifier: "Root element (`$module`)"
+ element: t,
+ identifier: "Root element (`$root`)"
});
- this.$module = e, this.config = mergeConfigs(NotificationBanner.defaults, t, normaliseDataset(NotificationBanner, e.dataset)), "alert" !== this.$module.getAttribute("role") || this.config.disableAutoFocus || setFocus(this.$module)
+ this.$root = t, this.config = mergeConfigs(NotificationBanner.defaults, e, normaliseDataset(NotificationBanner, t.dataset)), "alert" !== this.$root.getAttribute("role") || this.config.disableAutoFocus || setFocus(this.$root)
}
}
NotificationBanner.moduleName = "govuk-notification-banner", NotificationBanner.defaults = Object.freeze({
@@ -805,13 +805,13 @@ NotificationBanner.moduleName = "govuk-notification-banner", NotificationBanner.
}
});
class PasswordInput extends GOVUKFrontendComponent {
- constructor(e, t = {}) {
- if (super(), this.$module = void 0, this.config = void 0, this.i18n = void 0, this.$input = void 0, this.$showHideButton = void 0, this.$screenReaderStatusMessage = void 0, !(e instanceof HTMLElement)) throw new ElementError({
+ constructor(t, e = {}) {
+ if (super(), this.$root = void 0, this.config = void 0, this.i18n = void 0, this.$input = void 0, this.$showHideButton = void 0, this.$screenReaderStatusMessage = void 0, !(t instanceof HTMLElement)) throw new ElementError({
componentName: "Password input",
- element: e,
- identifier: "Root element (`$module`)"
+ element: t,
+ identifier: "Root element (`$root`)"
});
- const n = e.querySelector(".govuk-js-password-input-input");
+ const n = t.querySelector(".govuk-js-password-input-input");
if (!(n instanceof HTMLInputElement)) throw new ElementError({
componentName: "Password input",
element: n,
@@ -819,7 +819,7 @@ class PasswordInput extends GOVUKFrontendComponent {
identifier: "Form field (`.govuk-js-password-input-input`)"
});
if ("password" !== n.type) throw new ElementError("Password input: Form field (`.govuk-js-password-input-input`) must be of type `password`.");
- const i = e.querySelector(".govuk-js-password-input-toggle");
+ const i = t.querySelector(".govuk-js-password-input-toggle");
if (!(i instanceof HTMLButtonElement)) throw new ElementError({
componentName: "Password input",
element: i,
@@ -827,16 +827,16 @@ class PasswordInput extends GOVUKFrontendComponent {
identifier: "Button (`.govuk-js-password-input-toggle`)"
});
if ("button" !== i.type) throw new ElementError("Password input: Button (`.govuk-js-password-input-toggle`) must be of type `button`.");
- this.$module = e, this.$input = n, this.$showHideButton = i, this.config = mergeConfigs(PasswordInput.defaults, t, normaliseDataset(PasswordInput, e.dataset)), this.i18n = new I18n(this.config.i18n, {
- locale: closestAttributeValue(e, "lang")
+ this.$root = t, this.$input = n, this.$showHideButton = i, this.config = mergeConfigs(PasswordInput.defaults, e, normaliseDataset(PasswordInput, t.dataset)), this.i18n = new I18n(this.config.i18n, {
+ locale: closestAttributeValue(t, "lang")
}), this.$showHideButton.removeAttribute("hidden");
- const s = document.createElement("div");
- s.className = "govuk-password-input__sr-status govuk-visually-hidden", s.setAttribute("aria-live", "polite"), this.$screenReaderStatusMessage = s, this.$input.insertAdjacentElement("afterend", s), this.$showHideButton.addEventListener("click", this.toggle.bind(this)), this.$input.form && this.$input.form.addEventListener("submit", (() => this.hide())), window.addEventListener("pageshow", (e => {
- e.persisted && "password" !== this.$input.type && this.hide()
+ const o = document.createElement("div");
+ o.className = "govuk-password-input__sr-status govuk-visually-hidden", o.setAttribute("aria-live", "polite"), this.$screenReaderStatusMessage = o, this.$input.insertAdjacentElement("afterend", o), this.$showHideButton.addEventListener("click", this.toggle.bind(this)), this.$input.form && this.$input.form.addEventListener("submit", (() => this.hide())), window.addEventListener("pageshow", (t => {
+ t.persisted && "password" !== this.$input.type && this.hide()
})), this.hide()
}
- toggle(e) {
- e.preventDefault(), "password" !== this.$input.type ? this.hide() : this.show()
+ toggle(t) {
+ t.preventDefault(), "password" !== this.$input.type ? this.hide() : this.show()
}
show() {
this.setType("text")
@@ -844,12 +844,12 @@ class PasswordInput extends GOVUKFrontendComponent {
hide() {
this.setType("password")
}
- setType(e) {
- if (e === this.$input.type) return;
- this.$input.setAttribute("type", e);
- const t = "password" === e,
- n = t ? "show" : "hide",
- i = t ? "passwordHidden" : "passwordShown";
+ setType(t) {
+ if (t === this.$input.type) return;
+ this.$input.setAttribute("type", t);
+ const e = "password" === t,
+ n = e ? "show" : "hide",
+ i = e ? "passwordHidden" : "passwordShown";
this.$showHideButton.innerText = this.i18n.t(`${n}Password`), this.$showHideButton.setAttribute("aria-label", this.i18n.t(`${n}PasswordAriaLabel`)), this.$screenReaderStatusMessage.innerText = this.i18n.t(`${i}Announcement`)
}
}
@@ -870,64 +870,64 @@ PasswordInput.moduleName = "govuk-password-input", PasswordInput.defaults = Obje
}
});
class Radios extends GOVUKFrontendComponent {
- constructor(e) {
- if (super(e), this.$module = void 0, this.$inputs = void 0, !(e instanceof HTMLElement)) throw new ElementError({
+ constructor(t) {
+ if (super(t), this.$root = void 0, this.$inputs = void 0, !(t instanceof HTMLElement)) throw new ElementError({
componentName: "Radios",
- element: e,
- identifier: "Root element (`$module`)"
+ element: t,
+ identifier: "Root element (`$root`)"
});
- const t = e.querySelectorAll('input[type="radio"]');
- if (!t.length) throw new ElementError({
+ const e = t.querySelectorAll('input[type="radio"]');
+ if (!e.length) throw new ElementError({
componentName: "Radios",
identifier: 'Form inputs (`<input type="radio">`)'
});
- this.$module = e, this.$inputs = t, this.$inputs.forEach((e => {
- const t = e.getAttribute("data-aria-controls");
- if (t) {
- if (!document.getElementById(t)) throw new ElementError({
+ this.$root = t, this.$inputs = e, this.$inputs.forEach((t => {
+ const e = t.getAttribute("data-aria-controls");
+ if (e) {
+ if (!document.getElementById(e)) throw new ElementError({
componentName: "Radios",
- identifier: `Conditional reveal (\`id="${t}"\`)`
+ identifier: `Conditional reveal (\`id="${e}"\`)`
});
- e.setAttribute("aria-controls", t), e.removeAttribute("data-aria-controls")
+ t.setAttribute("aria-controls", e), t.removeAttribute("data-aria-controls")
}
- })), window.addEventListener("pageshow", (() => this.syncAllConditionalReveals())), this.syncAllConditionalReveals(), this.$module.addEventListener("click", (e => this.handleClick(e)))
+ })), window.addEventListener("pageshow", (() => this.syncAllConditionalReveals())), this.syncAllConditionalReveals(), this.$root.addEventListener("click", (t => this.handleClick(t)))
}
syncAllConditionalReveals() {
- this.$inputs.forEach((e => this.syncConditionalRevealWithInputState(e)))
+ this.$inputs.forEach((t => this.syncConditionalRevealWithInputState(t)))
}
- syncConditionalRevealWithInputState(e) {
- const t = e.getAttribute("aria-controls");
- if (!t) return;
- const n = document.getElementById(t);
+ syncConditionalRevealWithInputState(t) {
+ const e = t.getAttribute("aria-controls");
+ if (!e) return;
+ const n = document.getElementById(e);
if (null != n && n.classList.contains("govuk-radios__conditional")) {
- const t = e.checked;
- e.setAttribute("aria-expanded", t.toString()), n.classList.toggle("govuk-radios__conditional--hidden", !t)
+ const e = t.checked;
+ t.setAttribute("aria-expanded", e.toString()), n.classList.toggle("govuk-radios__conditional--hidden", !e)
}
}
- handleClick(e) {
- const t = e.target;
- if (!(t instanceof HTMLInputElement) || "radio" !== t.type) return;
+ handleClick(t) {
+ const e = t.target;
+ if (!(e instanceof HTMLInputElement) || "radio" !== e.type) return;
const n = document.querySelectorAll('input[type="radio"][aria-controls]'),
- i = t.form,
- s = t.name;
- n.forEach((e => {
- const t = e.form === i;
- e.name === s && t && this.syncConditionalRevealWithInputState(e)
+ i = e.form,
+ o = e.name;
+ n.forEach((t => {
+ const e = t.form === i;
+ t.name === o && e && this.syncConditionalRevealWithInputState(t)
}))
}
}
Radios.moduleName = "govuk-radios";
class ServiceNavigation extends GOVUKFrontendComponent {
- constructor(e) {
- if (super(), this.$module = void 0, this.$menuButton = void 0, this.$menu = void 0, this.menuIsOpen = !1, this.mql = null, !e) throw new ElementError({
+ constructor(t) {
+ if (super(), this.$root = void 0, this.$menuButton = void 0, this.$menu = void 0, this.menuIsOpen = !1, this.mql = null, !t) throw new ElementError({
componentName: "Service Navigation",
- element: e,
- identifier: "Root element (`$module`)"
+ element: t,
+ identifier: "Root element (`$root`)"
});
- this.$module = e;
- const t = e.querySelector(".govuk-js-service-navigation-toggle");
- if (!t) return this;
- const n = t.getAttribute("aria-controls");
+ this.$root = t;
+ const e = t.querySelector(".govuk-js-service-navigation-toggle");
+ if (!e) return this;
+ const n = e.getAttribute("aria-controls");
if (!n) throw new ElementError({
componentName: "Service Navigation",
identifier: 'Navigation button (`<button class="govuk-js-service-navigation-toggle">`) attribute (`aria-controls`)'
@@ -938,15 +938,15 @@ class ServiceNavigation extends GOVUKFrontendComponent {
element: i,
identifier: `Navigation (\`<ul id="${n}">\`)`
});
- this.$menu = i, this.$menuButton = t, this.setupResponsiveChecks(), this.$menuButton.addEventListener("click", (() => this.handleMenuButtonClick()))
+ this.$menu = i, this.$menuButton = e, this.setupResponsiveChecks(), this.$menuButton.addEventListener("click", (() => this.handleMenuButtonClick()))
}
setupResponsiveChecks() {
- const e = getBreakpoint("tablet");
- if (!e.value) throw new ElementError({
+ const t = getBreakpoint("tablet");
+ if (!t.value) throw new ElementError({
componentName: "Service Navigation",
- identifier: `CSS custom property (\`${e.property}\`) on pseudo-class \`:root\``
+ identifier: `CSS custom property (\`${t.property}\`) on pseudo-class \`:root\``
});
- this.mql = window.matchMedia(`(min-width: ${e.value})`), "addEventListener" in this.mql ? this.mql.addEventListener("change", (() => this.checkMode())) : this.mql.addListener((() => this.checkMode())), this.checkMode()
+ this.mql = window.matchMedia(`(min-width: ${t.value})`), "addEventListener" in this.mql ? this.mql.addEventListener("change", (() => this.checkMode())) : this.mql.addListener((() => this.checkMode())), this.checkMode()
}
checkMode() {
this.mql && this.$menu && this.$menuButton && (this.mql.matches ? (this.$menu.removeAttribute("hidden"), this.$menuButton.setAttribute("hidden", "")) : (this.$menuButton.removeAttribute("hidden"), this.$menuButton.setAttribute("aria-expanded", this.menuIsOpen.toString()), this.menuIsOpen ? this.$menu.removeAttribute("hidden") : this.$menu.setAttribute("hidden", "")))
@@ -957,33 +957,33 @@ class ServiceNavigation extends GOVUKFrontendComponent {
}
ServiceNavigation.moduleName = "govuk-service-navigation";
class SkipLink extends GOVUKFrontendComponent {
- constructor(e) {
- var t;
- if (super(e), this.$module = void 0, !(e instanceof HTMLAnchorElement)) throw new ElementError({
+ constructor(t) {
+ var e;
+ if (super(t), this.$root = void 0, !(t instanceof HTMLAnchorElement)) throw new ElementError({
componentName: "Skip link",
- element: e,
+ element: t,
expectedType: "HTMLAnchorElement",
- identifier: "Root element (`$module`)"
+ identifier: "Root element (`$root`)"
});
- this.$module = e;
- const n = this.$module.hash,
- i = null != (t = this.$module.getAttribute("href")) ? t : "";
- let s;
+ this.$root = t;
+ const n = this.$root.hash,
+ i = null != (e = this.$root.getAttribute("href")) ? e : "";
+ let o;
try {
- s = new window.URL(this.$module.href)
+ o = new window.URL(this.$root.href)
} catch (a) {
throw new ElementError(`Skip link: Target link (\`href="${i}"\`) is invalid`)
}
- if (s.origin !== window.location.origin || s.pathname !== window.location.pathname) return;
- const o = getFragmentFromUrl(n);
- if (!o) throw new ElementError(`Skip link: Target link (\`href="${i}"\`) has no hash fragment`);
- const r = document.getElementById(o);
+ if (o.origin !== window.location.origin || o.pathname !== window.location.pathname) return;
+ const s = getFragmentFromUrl(n);
+ if (!s) throw new ElementError(`Skip link: Target link (\`href="${i}"\`) has no hash fragment`);
+ const r = document.getElementById(s);
if (!r) throw new ElementError({
componentName: "Skip link",
element: r,
- identifier: `Target content (\`id="${o}"\`)`
+ identifier: `Target content (\`id="${s}"\`)`
});
- this.$module.addEventListener("click", (() => setFocus(r, {
+ this.$root.addEventListener("click", (() => setFocus(r, {
onBeforeFocus() {
r.classList.add("govuk-skip-link-focused-element")
},
@@ -995,20 +995,20 @@ class SkipLink extends GOVUKFrontendComponent {
}
SkipLink.moduleName = "govuk-skip-link";
class Tabs extends GOVUKFrontendComponent {
- constructor(e) {
- if (super(e), this.$module = void 0, this.$tabs = void 0, this.$tabList = void 0, this.$tabListItems = void 0, this.jsHiddenClass = "govuk-tabs__panel--hidden", this.changingHash = !1, this.boundTabClick = void 0, this.boundTabKeydown = void 0, this.boundOnHashChange = void 0, this.mql = null, !e) throw new ElementError({
+ constructor(t) {
+ if (super(t), this.$root = void 0, this.$tabs = void 0, this.$tabList = void 0, this.$tabListItems = void 0, this.jsHiddenClass = "govuk-tabs__panel--hidden", this.changingHash = !1, this.boundTabClick = void 0, this.boundTabKeydown = void 0, this.boundOnHashChange = void 0, this.mql = null, !t) throw new ElementError({
componentName: "Tabs",
- element: e,
- identifier: "Root element (`$module`)"
+ element: t,
+ identifier: "Root element (`$root`)"
});
- const t = e.querySelectorAll("a.govuk-tabs__tab");
- if (!t.length) throw new ElementError({
+ const e = t.querySelectorAll("a.govuk-tabs__tab");
+ if (!e.length) throw new ElementError({
componentName: "Tabs",
identifier: 'Links (`<a class="govuk-tabs__tab">`)'
});
- this.$module = e, this.$tabs = t, this.boundTabClick = this.onTabClick.bind(this), this.boundTabKeydown = this.onTabKeydown.bind(this), this.boundOnHashChange = this.onHashChange.bind(this);
- const n = this.$module.querySelector(".govuk-tabs__list"),
- i = this.$module.querySelectorAll("li.govuk-tabs__list-item");
+ this.$root = t, this.$tabs = e, this.boundTabClick = this.onTabClick.bind(this), this.boundTabKeydown = this.onTabKeydown.bind(this), this.boundOnHashChange = this.onHashChange.bind(this);
+ const n = this.$root.querySelector(".govuk-tabs__list"),
+ i = this.$root.querySelectorAll("li.govuk-tabs__list-item");
if (!n) throw new ElementError({
componentName: "Tabs",
identifier: 'List (`<ul class="govuk-tabs__list">`)'
@@ -1020,172 +1020,172 @@ class Tabs extends GOVUKFrontendComponent {
this.$tabList = n, this.$tabListItems = i, this.setupResponsiveChecks()
}
setupResponsiveChecks() {
- const e = getBreakpoint("tablet");
- if (!e.value) throw new ElementError({
+ const t = getBreakpoint("tablet");
+ if (!t.value) throw new ElementError({
componentName: "Tabs",
- identifier: `CSS custom property (\`${e.property}\`) on pseudo-class \`:root\``
+ identifier: `CSS custom property (\`${t.property}\`) on pseudo-class \`:root\``
});
- this.mql = window.matchMedia(`(min-width: ${e.value})`), "addEventListener" in this.mql ? this.mql.addEventListener("change", (() => this.checkMode())) : this.mql.addListener((() => this.checkMode())), this.checkMode()
+ this.mql = window.matchMedia(`(min-width: ${t.value})`), "addEventListener" in this.mql ? this.mql.addEventListener("change", (() => this.checkMode())) : this.mql.addListener((() => this.checkMode())), this.checkMode()
}
checkMode() {
- var e;
- null != (e = this.mql) && e.matches ? this.setup() : this.teardown()
+ var t;
+ null != (t = this.mql) && t.matches ? this.setup() : this.teardown()
}
setup() {
- var e;
- this.$tabList.setAttribute("role", "tablist"), this.$tabListItems.forEach((e => {
- e.setAttribute("role", "presentation")
- })), this.$tabs.forEach((e => {
- this.setAttributes(e), e.addEventListener("click", this.boundTabClick, !0), e.addEventListener("keydown", this.boundTabKeydown, !0), this.hideTab(e)
+ var t;
+ this.$tabList.setAttribute("role", "tablist"), this.$tabListItems.forEach((t => {
+ t.setAttribute("role", "presentation")
+ })), this.$tabs.forEach((t => {
+ this.setAttributes(t), t.addEventListener("click", this.boundTabClick, !0), t.addEventListener("keydown", this.boundTabKeydown, !0), this.hideTab(t)
}));
- const t = null != (e = this.getTab(window.location.hash)) ? e : this.$tabs[0];
- this.showTab(t), window.addEventListener("hashchange", this.boundOnHashChange, !0)
+ const e = null != (t = this.getTab(window.location.hash)) ? t : this.$tabs[0];
+ this.showTab(e), window.addEventListener("hashchange", this.boundOnHashChange, !0)
}
teardown() {
- this.$tabList.removeAttribute("role"), this.$tabListItems.forEach((e => {
- e.removeAttribute("role")
- })), this.$tabs.forEach((e => {
- e.removeEventListener("click", this.boundTabClick, !0), e.removeEventListener("keydown", this.boundTabKeydown, !0), this.unsetAttributes(e)
+ this.$tabList.removeAttribute("role"), this.$tabListItems.forEach((t => {
+ t.removeAttribute("role")
+ })), this.$tabs.forEach((t => {
+ t.removeEventListener("click", this.boundTabClick, !0), t.removeEventListener("keydown", this.boundTabKeydown, !0), this.unsetAttributes(t)
})), window.removeEventListener("hashchange", this.boundOnHashChange, !0)
}
onHashChange() {
- const e = window.location.hash,
- t = this.getTab(e);
- if (!t) return;
+ const t = window.location.hash,
+ e = this.getTab(t);
+ if (!e) return;
if (this.changingHash) return void(this.changingHash = !1);
const n = this.getCurrentTab();
- n && (this.hideTab(n), this.showTab(t), t.focus())
- }
- hideTab(e) {
- this.unhighlightTab(e), this.hidePanel(e)
- }
- showTab(e) {
- this.highlightTab(e), this.showPanel(e)
- }
- getTab(e) {
- return this.$module.querySelector(`a.govuk-tabs__tab[href="${e}"]`)
- }
- setAttributes(e) {
- const t = getFragmentFromUrl(e.href);
- if (!t) return;
- e.setAttribute("id", `tab_${t}`), e.setAttribute("role", "tab"), e.setAttribute("aria-controls", t), e.setAttribute("aria-selected", "false"), e.setAttribute("tabindex", "-1");
- const n = this.getPanel(e);
- n && (n.setAttribute("role", "tabpanel"), n.setAttribute("aria-labelledby", e.id), n.classList.add(this.jsHiddenClass))
- }
- unsetAttributes(e) {
- e.removeAttribute("id"), e.removeAttribute("role"), e.removeAttribute("aria-controls"), e.removeAttribute("aria-selected"), e.removeAttribute("tabindex");
- const t = this.getPanel(e);
- t && (t.removeAttribute("role"), t.removeAttribute("aria-labelledby"), t.classList.remove(this.jsHiddenClass))
- }
- onTabClick(e) {
- const t = this.getCurrentTab(),
- n = e.currentTarget;
- t && n instanceof HTMLAnchorElement && (e.preventDefault(), this.hideTab(t), this.showTab(n), this.createHistoryEntry(n))
- }
- createHistoryEntry(e) {
- const t = this.getPanel(e);
- if (!t) return;
- const n = t.id;
- t.id = "", this.changingHash = !0, window.location.hash = n, t.id = n
- }
- onTabKeydown(e) {
- switch (e.key) {
+ n && (this.hideTab(n), this.showTab(e), e.focus())
+ }
+ hideTab(t) {
+ this.unhighlightTab(t), this.hidePanel(t)
+ }
+ showTab(t) {
+ this.highlightTab(t), this.showPanel(t)
+ }
+ getTab(t) {
+ return this.$root.querySelector(`a.govuk-tabs__tab[href="${t}"]`)
+ }
+ setAttributes(t) {
+ const e = getFragmentFromUrl(t.href);
+ if (!e) return;
+ t.setAttribute("id", `tab_${e}`), t.setAttribute("role", "tab"), t.setAttribute("aria-controls", e), t.setAttribute("aria-selected", "false"), t.setAttribute("tabindex", "-1");
+ const n = this.getPanel(t);
+ n && (n.setAttribute("role", "tabpanel"), n.setAttribute("aria-labelledby", t.id), n.classList.add(this.jsHiddenClass))
+ }
+ unsetAttributes(t) {
+ t.removeAttribute("id"), t.removeAttribute("role"), t.removeAttribute("aria-controls"), t.removeAttribute("aria-selected"), t.removeAttribute("tabindex");
+ const e = this.getPanel(t);
+ e && (e.removeAttribute("role"), e.removeAttribute("aria-labelledby"), e.classList.remove(this.jsHiddenClass))
+ }
+ onTabClick(t) {
+ const e = this.getCurrentTab(),
+ n = t.currentTarget;
+ e && n instanceof HTMLAnchorElement && (t.preventDefault(), this.hideTab(e), this.showTab(n), this.createHistoryEntry(n))
+ }
+ createHistoryEntry(t) {
+ const e = this.getPanel(t);
+ if (!e) return;
+ const n = e.id;
+ e.id = "", this.changingHash = !0, window.location.hash = n, e.id = n
+ }
+ onTabKeydown(t) {
+ switch (t.key) {
case "ArrowLeft":
case "Left":
- this.activatePreviousTab(), e.preventDefault();
+ this.activatePreviousTab(), t.preventDefault();
break;
case "ArrowRight":
case "Right":
- this.activateNextTab(), e.preventDefault()
+ this.activateNextTab(), t.preventDefault()
}
}
activateNextTab() {
- const e = this.getCurrentTab();
- if (null == e || !e.parentElement) return;
- const t = e.parentElement.nextElementSibling;
- if (!t) return;
- const n = t.querySelector("a.govuk-tabs__tab");
- n && (this.hideTab(e), this.showTab(n), n.focus(), this.createHistoryEntry(n))
+ const t = this.getCurrentTab();
+ if (null == t || !t.parentElement) return;
+ const e = t.parentElement.nextElementSibling;
+ if (!e) return;
+ const n = e.querySelector("a.govuk-tabs__tab");
+ n && (this.hideTab(t), this.showTab(n), n.focus(), this.createHistoryEntry(n))
}
activatePreviousTab() {
- const e = this.getCurrentTab();
- if (null == e || !e.parentElement) return;
- const t = e.parentElement.previousElementSibling;
- if (!t) return;
- const n = t.querySelector("a.govuk-tabs__tab");
- n && (this.hideTab(e), this.showTab(n), n.focus(), this.createHistoryEntry(n))
+ const t = this.getCurrentTab();
+ if (null == t || !t.parentElement) return;
+ const e = t.parentElement.previousElementSibling;
+ if (!e) return;
+ const n = e.querySelector("a.govuk-tabs__tab");
+ n && (this.hideTab(t), this.showTab(n), n.focus(), this.createHistoryEntry(n))
}
- getPanel(e) {
- const t = getFragmentFromUrl(e.href);
- return t ? this.$module.querySelector(`#${t}`) : null
+ getPanel(t) {
+ const e = getFragmentFromUrl(t.href);
+ return e ? this.$root.querySelector(`#${e}`) : null
}
- showPanel(e) {
- const t = this.getPanel(e);
- t && t.classList.remove(this.jsHiddenClass)
+ showPanel(t) {
+ const e = this.getPanel(t);
+ e && e.classList.remove(this.jsHiddenClass)
}
- hidePanel(e) {
- const t = this.getPanel(e);
- t && t.classList.add(this.jsHiddenClass)
+ hidePanel(t) {
+ const e = this.getPanel(t);
+ e && e.classList.add(this.jsHiddenClass)
}
- unhighlightTab(e) {
- e.parentElement && (e.setAttribute("aria-selected", "false"), e.parentElement.classList.remove("govuk-tabs__list-item--selected"), e.setAttribute("tabindex", "-1"))
+ unhighlightTab(t) {
+ t.parentElement && (t.setAttribute("aria-selected", "false"), t.parentElement.classList.remove("govuk-tabs__list-item--selected"), t.setAttribute("tabindex", "-1"))
}
- highlightTab(e) {
- e.parentElement && (e.setAttribute("aria-selected", "true"), e.parentElement.classList.add("govuk-tabs__list-item--selected"), e.setAttribute("tabindex", "0"))
+ highlightTab(t) {
+ t.parentElement && (t.setAttribute("aria-selected", "true"), t.parentElement.classList.add("govuk-tabs__list-item--selected"), t.setAttribute("tabindex", "0"))
}
getCurrentTab() {
- return this.$module.querySelector(".govuk-tabs__list-item--selected a.govuk-tabs__tab")
+ return this.$root.querySelector(".govuk-tabs__list-item--selected a.govuk-tabs__tab")
}
}
-function initAll(e) {
- var t;
- if (e = void 0 !== e ? e : {}, !isSupported()) return void(e.onError ? e.onError(new SupportError, {
- config: e
+function initAll(t) {
+ var e;
+ if (t = void 0 !== t ? t : {}, !isSupported()) return void(t.onError ? t.onError(new SupportError, {
+ config: t
}) : console.log(new SupportError));
const n = [
- [Accordion, e.accordion],
- [Button, e.button],
- [CharacterCount, e.characterCount],
+ [Accordion, t.accordion],
+ [Button, t.button],
+ [CharacterCount, t.characterCount],
[Checkboxes],
- [ErrorSummary, e.errorSummary],
- [ExitThisPage, e.exitThisPage],
+ [ErrorSummary, t.errorSummary],
+ [ExitThisPage, t.exitThisPage],
[Header],
- [NotificationBanner, e.notificationBanner],
- [PasswordInput, e.passwordInput],
+ [NotificationBanner, t.notificationBanner],
+ [PasswordInput, t.passwordInput],
[Radios],
[ServiceNavigation],
[SkipLink],
[Tabs]
],
i = {
- scope: null != (t = e.scope) ? t : document,
- onError: e.onError
+ scope: null != (e = t.scope) ? e : document,
+ onError: t.onError
};
- n.forEach((([e, t]) => {
- createAll(e, t, i)
+ n.forEach((([t, e]) => {
+ createAll(t, e, i)
}))
}
-function createAll(e, t, n) {
- let i, s = document;
- var o;
- "object" == typeof n && (s = null != (o = n.scope) ? o : s, i = n.onError);
- "function" == typeof n && (i = n), n instanceof HTMLElement && (s = n);
- const r = s.querySelectorAll(`[data-module="${e.moduleName}"]`);
+function createAll(t, e, n) {
+ let i, o = document;
+ var s;
+ "object" == typeof n && (o = null != (s = n.scope) ? s : o, i = n.onError);
+ "function" == typeof n && (i = n), n instanceof HTMLElement && (o = n);
+ const r = o.querySelectorAll(`[data-module="${t.moduleName}"]`);
return isSupported() ? Array.from(r).map((n => {
try {
- return "defaults" in e && void 0 !== t ? new e(n, t) : new e(n)
- } catch (s) {
- return i && s instanceof Error ? i(s, {
+ return "defaults" in t && void 0 !== e ? new t(n, e) : new t(n)
+ } catch (o) {
+ return i && o instanceof Error ? i(o, {
element: n,
- component: e,
- config: t
- }) : console.log(s), null
+ component: t,
+ config: e
+ }) : console.log(o), null
}
})).filter(Boolean) : (i ? i(new SupportError, {
- component: e,
- config: t
+ component: t,
+ config: e
}) : console.log(new SupportError), [])
}
Tabs.moduleName = "govuk-tabs";
Action run for 73f79a7 |
Other changes to npm packagediff --git a/packages/govuk-frontend/dist/govuk/all.bundle.js b/packages/govuk-frontend/dist/govuk/all.bundle.js
index 1c67edb22..e92873a32 100644
--- a/packages/govuk-frontend/dist/govuk/all.bundle.js
+++ b/packages/govuk-frontend/dist/govuk/all.bundle.js
@@ -114,8 +114,8 @@
(_options$onBeforeFocu = options.onBeforeFocus) == null || _options$onBeforeFocu.call($element);
$element.focus();
}
- function isInitialised($module, moduleName) {
- return $module instanceof HTMLElement && $module.hasAttribute(`data-${moduleName}-init`);
+ function isInitialised($root, moduleName) {
+ return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
}
/**
@@ -241,7 +241,7 @@
constructor(moduleName, className) {
let errorText = `moduleName not defined in component (\`${className}\`)`;
if (typeof moduleName === 'string') {
- errorText = `Root element (\`$module\`) already initialised (\`${moduleName}\`)`;
+ errorText = `Root element (\`$root\`) already initialised (\`${moduleName}\`)`;
}
super(errorText);
this.name = 'InitError';
@@ -249,19 +249,19 @@
}
class GOVUKFrontendComponent {
- constructor($module) {
+ constructor($root) {
this.checkSupport();
- this.checkInitialised($module);
+ this.checkInitialised($root);
const moduleName = this.constructor.moduleName;
if (typeof moduleName === 'string') {
- moduleName && ($module == null ? void 0 : $module.setAttribute(`data-${moduleName}-init`, ''));
+ moduleName && ($root == null ? void 0 : $root.setAttribute(`data-${moduleName}-init`, ''));
} else {
throw new InitError(moduleName);
}
}
- checkInitialised($module) {
+ checkInitialised($root) {
const moduleName = this.constructor.moduleName;
- if ($module && moduleName && isInitialised($module, moduleName)) {
+ if ($root && moduleName && isInitialised($root, moduleName)) {
throw new InitError(moduleName);
}
}
@@ -500,12 +500,12 @@
*/
class Accordion extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for accordion
+ * @param {Element | null} $root - HTML element to use for accordion
* @param {AccordionConfig} [config] - Accordion config
*/
- constructor($module, config = {}) {
- super($module);
- this.$module = void 0;
+ constructor($root, config = {}) {
+ super($root);
+ this.$root = void 0;
this.config = void 0;
this.i18n = void 0;
this.controlsClass = 'govuk-accordion__controls';
@@ -531,17 +531,17 @@
this.$showAllButton = null;
this.$showAllIcon = null;
this.$showAllText = null;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Accordion',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- this.$module = $module;
- this.config = mergeConfigs(Accordion.defaults, config, normaliseDataset(Accordion, $module.dataset));
+ this.$root = $root;
+ this.config = mergeConfigs(Accordion.defaults, config, normaliseDataset(Accordion, $root.dataset));
this.i18n = new I18n(this.config.i18n);
- const $sections = this.$module.querySelectorAll(`.${this.sectionClass}`);
+ const $sections = this.$root.querySelectorAll(`.${this.sectionClass}`);
if (!$sections.length) {
throw new ElementError({
componentName: 'Accordion',
@@ -564,7 +564,7 @@
const $accordionControls = document.createElement('div');
$accordionControls.setAttribute('class', this.controlsClass);
$accordionControls.appendChild(this.$showAllButton);
- this.$module.insertBefore($accordionControls, this.$module.firstChild);
+ this.$root.insertBefore($accordionControls, this.$root.firstChild);
this.$showAllText = document.createElement('span');
this.$showAllText.classList.add(this.showAllTextClass);
this.$showAllButton.appendChild(this.$showAllText);
@@ -606,7 +606,7 @@
}
const $button = document.createElement('button');
$button.setAttribute('type', 'button');
- $button.setAttribute('aria-controls', `${this.$module.id}-content-${index + 1}`);
+ $button.setAttribute('aria-controls', `${this.$root.id}-content-${index + 1}`);
for (const attr of Array.from($span.attributes)) {
if (attr.name !== 'id') {
$button.setAttribute(attr.name, attr.value);
@@ -843,25 +843,25 @@
*/
class Button extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for button
+ * @param {Element | null} $root - HTML element to use for button
* @param {ButtonConfig} [config] - Button config
*/
- constructor($module, config = {}) {
- super($module);
- this.$module = void 0;
+ constructor($root, config = {}) {
+ super($root);
+ this.$root = void 0;
this.config = void 0;
this.debounceFormSubmitTimer = null;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Button',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- this.$module = $module;
- this.config = mergeConfigs(Button.defaults, config, normaliseDataset(Button, $module.dataset));
- this.$module.addEventListener('keydown', event => this.handleKeyDown(event));
- this.$module.addEventListener('click', event => this.debounce(event));
+ this.$root = $root;
+ this.config = mergeConfigs(Button.defaults, config, normaliseDataset(Button, $root.dataset));
+ this.$root.addEventListener('keydown', event => this.handleKeyDown(event));
+ this.$root.addEventListener('click', event => this.debounce(event));
}
handleKeyDown(event) {
const $target = event.target;
@@ -929,13 +929,13 @@
*/
class CharacterCount extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for character count
+ * @param {Element | null} $root - HTML element to use for character count
* @param {CharacterCountConfig} [config] - Character count config
*/
- constructor($module, config = {}) {
+ constructor($root, config = {}) {
var _ref, _this$config$maxwords;
- super($module);
- this.$module = void 0;
+ super($root);
+ this.$root = void 0;
this.$textarea = void 0;
this.$visibleCountMessage = void 0;
this.$screenReaderCountMessage = void 0;
@@ -945,14 +945,14 @@
this.config = void 0;
this.i18n = void 0;
this.maxLength = void 0;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Character count',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- const $textarea = $module.querySelector('.govuk-js-character-count');
+ const $textarea = $root.querySelector('.govuk-js-character-count');
if (!($textarea instanceof HTMLTextAreaElement || $textarea instanceof HTMLInputElement)) {
throw new ElementError({
componentName: 'Character count',
@@ -961,7 +961,7 @@
identifier: 'Form field (`.govuk-js-character-count`)'
});
}
- const datasetConfig = normaliseDataset(CharacterCount, $module.dataset);
+ const datasetConfig = normaliseDataset(CharacterCount, $root.dataset);
let configOverrides = {};
if ('maxwords' in datasetConfig || 'maxlength' in datasetConfig) {
configOverrides = {
@@ -975,10 +975,10 @@
throw new ConfigError(`Character count: ${errors[0]}`);
}
this.i18n = new I18n(this.config.i18n, {
- locale: closestAttributeValue($module, 'lang')
+ locale: closestAttributeValue($root, 'lang')
});
this.maxLength = (_ref = (_this$config$maxwords = this.config.maxwords) != null ? _this$config$maxwords : this.config.maxlength) != null ? _ref : Infinity;
- this.$module = $module;
+ this.$root = $root;
this.$textarea = $textarea;
const textareaDescriptionId = `${this.$textarea.id}-info`;
const $textareaDescription = document.getElementById(textareaDescriptionId);
@@ -1228,27 +1228,27 @@
* (for example if the user has navigated back), and set up event handlers to
* keep the reveal in sync with the checkbox state.
*
- * @param {Element | null} $module - HTML element to use for checkboxes
+ * @param {Element | null} $root - HTML element to use for checkboxes
*/
- constructor($module) {
- super($module);
- this.$module = void 0;
+ constructor($root) {
+ super($root);
+ this.$root = void 0;
this.$inputs = void 0;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Checkboxes',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- const $inputs = $module.querySelectorAll('input[type="checkbox"]');
+ const $inputs = $root.querySelectorAll('input[type="checkbox"]');
if (!$inputs.length) {
throw new ElementError({
componentName: 'Checkboxes',
identifier: 'Form inputs (`<input type="checkbox">`)'
});
}
- this.$module = $module;
+ this.$root = $root;
this.$inputs = $inputs;
this.$inputs.forEach($input => {
const targetId = $input.getAttribute('data-aria-controls');
@@ -1266,7 +1266,7 @@
});
window.addEventListener('pageshow', () => this.syncAllConditionalReveals());
this.syncAllConditionalReveals();
- this.$module.addEventListener('click', event => this.handleClick(event));
+ this.$root.addEventListener('click', event => this.handleClick(event));
}
syncAllConditionalReveals() {
this.$inputs.forEach($input => this.syncConditionalRevealWithInputState($input));
@@ -1335,26 +1335,26 @@
*/
class ErrorSummary extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for error summary
+ * @param {Element | null} $root - HTML element to use for error summary
* @param {ErrorSummaryConfig} [config] - Error summary config
*/
- constructor($module, config = {}) {
- super($module);
- this.$module = void 0;
+ constructor($root, config = {}) {
+ super($root);
+ this.$root = void 0;
this.config = void 0;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Error summary',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- this.$module = $module;
- this.config = mergeConfigs(ErrorSummary.defaults, config, normaliseDataset(ErrorSummary, $module.dataset));
+ this.$root = $root;
+ this.config = mergeConfigs(ErrorSummary.defaults, config, normaliseDataset(ErrorSummary, $root.dataset));
if (!this.config.disableAutoFocus) {
- setFocus(this.$module);
+ setFocus(this.$root);
}
- this.$module.addEventListener('click', event => this.handleClick(event));
+ this.$root.addEventListener('click', event => this.handleClick(event));
}
handleClick(event) {
const $target = event.target;
@@ -1438,12 +1438,12 @@
*/
class ExitThisPage extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element that wraps the Exit This Page button
+ * @param {Element | null} $root - HTML element that wraps the Exit This Page button
* @param {ExitThisPageConfig} [config] - Exit This Page config
*/
- constructor($module, config = {}) {
- super($module);
- this.$module = void 0;
+ constructor($root, config = {}) {
+ super($root);
+ this.$root = void 0;
this.config = void 0;
this.i18n = void 0;
this.$button = void 0;
@@ -1456,14 +1456,14 @@
this.timeoutTime = 5000;
this.keypressTimeoutId = null;
this.timeoutMessageId = null;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Exit this page',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- const $button = $module.querySelector('.govuk-exit-this-page__button');
+ const $button = $root.querySelector('.govuk-exit-this-page__button');
if (!($button instanceof HTMLAnchorElement)) {
throw new ElementError({
componentName: 'Exit this page',
@@ -1472,9 +1472,9 @@
identifier: 'Button (`.govuk-exit-this-page__button`)'
});
}
- this.config = mergeConfigs(ExitThisPage.defaults, config, normaliseDataset(ExitThisPage, $module.dataset));
+ this.config = mergeConfigs(ExitThisPage.defaults, config, normaliseDataset(ExitThisPage, $root.dataset));
this.i18n = new I18n(this.config.i18n);
- this.$module = $module;
+ this.$root = $root;
this.$button = $button;
const $skiplinkButton = document.querySelector('.govuk-js-exit-this-page-skiplink');
if ($skiplinkButton instanceof HTMLAnchorElement) {
@@ -1493,7 +1493,7 @@
this.$updateSpan = document.createElement('span');
this.$updateSpan.setAttribute('role', 'status');
this.$updateSpan.className = 'govuk-visually-hidden';
- this.$module.appendChild(this.$updateSpan);
+ this.$root.appendChild(this.$updateSpan);
}
initButtonClickHandler() {
this.$button.addEventListener('click', this.handleClick.bind(this));
@@ -1668,24 +1668,24 @@
* Apply a matchMedia for desktop which will trigger a state sync if the
* browser viewport moves between states.
*
- * @param {Element | null} $module - HTML element to use for header
+ * @param {Element | null} $root - HTML element to use for header
*/
- constructor($module) {
- super($module);
- this.$module = void 0;
+ constructor($root) {
+ super($root);
+ this.$root = void 0;
this.$menuButton = void 0;
this.$menu = void 0;
this.menuIsOpen = false;
this.mql = null;
- if (!$module) {
+ if (!$root) {
throw new ElementError({
componentName: 'Header',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- this.$module = $module;
- const $menuButton = $module.querySelector('.govuk-js-header-toggle');
+ this.$root = $root;
+ const $menuButton = $root.querySelector('.govuk-js-header-toggle');
if (!$menuButton) {
return this;
}
@@ -1756,24 +1756,24 @@
*/
class NotificationBanner extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for notification banner
+ * @param {Element | null} $root - HTML element to use for notification banner
* @param {NotificationBannerConfig} [config] - Notification banner config
*/
- constructor($module, config = {}) {
- super($module);
- this.$module = void 0;
+ constructor($root, config = {}) {
+ super($root);
+ this.$root = void 0;
this.config = void 0;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Notification banner',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- this.$module = $module;
- this.config = mergeConfigs(NotificationBanner.defaults, config, normaliseDataset(NotificationBanner, $module.dataset));
- if (this.$module.getAttribute('role') === 'alert' && !this.config.disableAutoFocus) {
- setFocus(this.$module);
+ this.$root = $root;
+ this.config = mergeConfigs(NotificationBanner.defaults, config, normaliseDataset(NotificationBanner, $root.dataset));
+ if (this.$root.getAttribute('role') === 'alert' && !this.config.disableAutoFocus) {
+ setFocus(this.$root);
}
}
}
@@ -1810,25 +1810,25 @@
*/
class PasswordInput extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for password input
+ * @param {Element | null} $root - HTML element to use for password input
* @param {PasswordInputConfig} [config] - Password input config
*/
- constructor($module, config = {}) {
+ constructor($root, config = {}) {
super();
- this.$module = void 0;
+ this.$root = void 0;
this.config = void 0;
this.i18n = void 0;
this.$input = void 0;
this.$showHideButton = void 0;
this.$screenReaderStatusMessage = void 0;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Password input',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- const $input = $module.querySelector('.govuk-js-password-input-input');
+ const $input = $root.querySelector('.govuk-js-password-input-input');
if (!($input instanceof HTMLInputElement)) {
throw new ElementError({
componentName: 'Password input',
@@ -1840,7 +1840,7 @@
if ($input.type !== 'password') {
throw new ElementError('Password input: Form field (`.govuk-js-password-input-input`) must be of type `password`.');
}
- const $showHideButton = $module.querySelector('.govuk-js-password-input-toggle');
+ const $showHideButton = $root.querySelector('.govuk-js-password-input-toggle');
if (!($showHideButton instanceof HTMLButtonElement)) {
throw new ElementError({
componentName: 'Password input',
@@ -1852,12 +1852,12 @@
if ($showHideButton.type !== 'button') {
throw new ElementError('Password input: Button (`.govuk-js-password-input-toggle`) must be of type `button`.');
}
- this.$module = $module;
+ this.$root = $root;
this.$input = $input;
this.$showHideButton = $showHideButton;
- this.config = mergeConfigs(PasswordInput.defaults, config, normaliseDataset(PasswordInput, $module.dataset));
+ this.config = mergeConfigs(PasswordInput.defaults, config, normaliseDataset(PasswordInput, $root.dataset));
this.i18n = new I18n(this.config.i18n, {
- locale: closestAttributeValue($module, 'lang')
+ locale: closestAttributeValue($root, 'lang')
});
this.$showHideButton.removeAttribute('hidden');
const $screenReaderStatusMessage = document.createElement('div');
@@ -1975,27 +1975,27 @@
* (for example if the user has navigated back), and set up event handlers to
* keep the reveal in sync with the radio state.
*
- * @param {Element | null} $module - HTML element to use for radios
+ * @param {Element | null} $root - HTML element to use for radios
*/
- constructor($module) {
- super($module);
- this.$module = void 0;
+ constructor($root) {
+ super($root);
+ this.$root = void 0;
this.$inputs = void 0;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Radios',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- const $inputs = $module.querySelectorAll('input[type="radio"]');
+ const $inputs = $root.querySelectorAll('input[type="radio"]');
if (!$inputs.length) {
throw new ElementError({
componentName: 'Radios',
identifier: 'Form inputs (`<input type="radio">`)'
});
}
- this.$module = $module;
+ this.$root = $root;
this.$inputs = $inputs;
this.$inputs.forEach($input => {
const targetId = $input.getAttribute('data-aria-controls');
@@ -2013,7 +2013,7 @@
});
window.addEventListener('pageshow', () => this.syncAllConditionalReveals());
this.syncAllConditionalReveals();
- this.$module.addEventListener('click', event => this.handleClick(event));
+ this.$root.addEventListener('click', event => this.handleClick(event));
}
syncAllConditionalReveals() {
this.$inputs.forEach($input => this.syncConditionalRevealWithInputState($input));
@@ -2056,24 +2056,24 @@
*/
class ServiceNavigation extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for header
+ * @param {Element | null} $root - HTML element to use for header
*/
- constructor($module) {
+ constructor($root) {
super();
- this.$module = void 0;
+ this.$root = void 0;
this.$menuButton = void 0;
this.$menu = void 0;
this.menuIsOpen = false;
this.mql = null;
- if (!$module) {
+ if (!$root) {
throw new ElementError({
componentName: 'Service Navigation',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- this.$module = $module;
- const $menuButton = $module.querySelector('.govuk-js-service-navigation-toggle');
+ this.$root = $root;
+ const $menuButton = $root.querySelector('.govuk-js-service-navigation-toggle');
if (!$menuButton) {
return this;
}
@@ -2144,29 +2144,29 @@
*/
class SkipLink extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for skip link
- * @throws {ElementError} when $module is not set or the wrong type
- * @throws {ElementError} when $module.hash does not contain a hash
+ * @param {Element | null} $root - HTML element to use for skip link
+ * @throws {ElementError} when $root is not set or the wrong type
+ * @throws {ElementError} when $root.hash does not contain a hash
* @throws {ElementError} when the linked element is missing or the wrong type
*/
- constructor($module) {
- var _this$$module$getAttr;
- super($module);
- this.$module = void 0;
- if (!($module instanceof HTMLAnchorElement)) {
+ constructor($root) {
+ var _this$$root$getAttrib;
+ super($root);
+ this.$root = void 0;
+ if (!($root instanceof HTMLAnchorElement)) {
throw new ElementError({
componentName: 'Skip link',
- element: $module,
+ element: $root,
expectedType: 'HTMLAnchorElement',
- identifier: 'Root element (`$module`)'
+ identifier: 'Root element (`$root`)'
});
}
- this.$module = $module;
- const hash = this.$module.hash;
- const href = (_this$$module$getAttr = this.$module.getAttribute('href')) != null ? _this$$module$getAttr : '';
+ this.$root = $root;
+ const hash = this.$root.hash;
+ const href = (_this$$root$getAttrib = this.$root.getAttribute('href')) != null ? _this$$root$getAttrib : '';
let url;
try {
- url = new window.URL(this.$module.href);
+ url = new window.URL(this.$root.href);
} catch (error) {
throw new ElementError(`Skip link: Target link (\`href="${href}"\`) is invalid`);
}
@@ -2185,7 +2185,7 @@
identifier: `Target content (\`id="${linkedElementId}"\`)`
});
}
- this.$module.addEventListener('click', () => setFocus($linkedElement, {
+ this.$root.addEventListener('click', () => setFocus($linkedElement, {
onBeforeFocus() {
$linkedElement.classList.add('govuk-skip-link-focused-element');
},
@@ -2204,11 +2204,11 @@
*/
class Tabs extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for tabs
+ * @param {Element | null} $root - HTML element to use for tabs
*/
- constructor($module) {
- super($module);
- this.$module = void 0;
+ constructor($root) {
+ super($root);
+ this.$root = void 0;
this.$tabs = void 0;
this.$tabList = void 0;
this.$tabListItems = void 0;
@@ -2218,27 +2218,27 @@
this.boundTabKeydown = void 0;
this.boundOnHashChange = void 0;
this.mql = null;
- if (!$module) {
+ if (!$root) {
throw new ElementError({
componentName: 'Tabs',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- const $tabs = $module.querySelectorAll('a.govuk-tabs__tab');
+ const $tabs = $root.querySelectorAll('a.govuk-tabs__tab');
if (!$tabs.length) {
throw new ElementError({
componentName: 'Tabs',
identifier: 'Links (`<a class="govuk-tabs__tab">`)'
});
}
- this.$module = $module;
+ this.$root = $root;
this.$tabs = $tabs;
this.boundTabClick = this.onTabClick.bind(this);
this.boundTabKeydown = this.onTabKeydown.bind(this);
this.boundOnHashChange = this.onHashChange.bind(this);
- const $tabList = this.$module.querySelector('.govuk-tabs__list');
- const $tabListItems = this.$module.querySelectorAll('li.govuk-tabs__list-item');
+ const $tabList = this.$root.querySelector('.govuk-tabs__list');
+ const $tabListItems = this.$root.querySelectorAll('li.govuk-tabs__list-item');
if (!$tabList) {
throw new ElementError({
componentName: 'Tabs',
@@ -2334,7 +2334,7 @@
this.showPanel($tab);
}
getTab(hash) {
- return this.$module.querySelector(`a.govuk-tabs__tab[href="${hash}"]`);
+ return this.$root.querySelector(`a.govuk-tabs__tab[href="${hash}"]`);
}
setAttributes($tab) {
const panelId = getFragmentFromUrl($tab.href);
@@ -2445,7 +2445,7 @@
if (!panelId) {
return null;
}
- return this.$module.querySelector(`#${panelId}`);
+ return this.$root.querySelector(`#${panelId}`);
}
showPanel($tab) {
const $panel = this.getPanel($tab);
@@ -2478,7 +2478,7 @@
$tab.setAttribute('tabindex', '0');
}
getCurrentTab() {
- return this.$module.querySelector('.govuk-tabs__list-item--selected a.govuk-tabs__tab');
+ return this.$root.querySelector('.govuk-tabs__list-item--selected a.govuk-tabs__tab');
}
}
Tabs.moduleName = 'govuk-tabs';
diff --git a/packages/govuk-frontend/dist/govuk/all.bundle.mjs b/packages/govuk-frontend/dist/govuk/all.bundle.mjs
index f8c1c3ed1..cc235e58c 100644
--- a/packages/govuk-frontend/dist/govuk/all.bundle.mjs
+++ b/packages/govuk-frontend/dist/govuk/all.bundle.mjs
@@ -108,8 +108,8 @@ function setFocus($element, options = {}) {
(_options$onBeforeFocu = options.onBeforeFocus) == null || _options$onBeforeFocu.call($element);
$element.focus();
}
-function isInitialised($module, moduleName) {
- return $module instanceof HTMLElement && $module.hasAttribute(`data-${moduleName}-init`);
+function isInitialised($root, moduleName) {
+ return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
}
/**
@@ -235,7 +235,7 @@ class InitError extends GOVUKFrontendError {
constructor(moduleName, className) {
let errorText = `moduleName not defined in component (\`${className}\`)`;
if (typeof moduleName === 'string') {
- errorText = `Root element (\`$module\`) already initialised (\`${moduleName}\`)`;
+ errorText = `Root element (\`$root\`) already initialised (\`${moduleName}\`)`;
}
super(errorText);
this.name = 'InitError';
@@ -243,19 +243,19 @@ class InitError extends GOVUKFrontendError {
}
class GOVUKFrontendComponent {
- constructor($module) {
+ constructor($root) {
this.checkSupport();
- this.checkInitialised($module);
+ this.checkInitialised($root);
const moduleName = this.constructor.moduleName;
if (typeof moduleName === 'string') {
- moduleName && ($module == null ? void 0 : $module.setAttribute(`data-${moduleName}-init`, ''));
+ moduleName && ($root == null ? void 0 : $root.setAttribute(`data-${moduleName}-init`, ''));
} else {
throw new InitError(moduleName);
}
}
- checkInitialised($module) {
+ checkInitialised($root) {
const moduleName = this.constructor.moduleName;
- if ($module && moduleName && isInitialised($module, moduleName)) {
+ if ($root && moduleName && isInitialised($root, moduleName)) {
throw new InitError(moduleName);
}
}
@@ -494,12 +494,12 @@ I18n.pluralRules = {
*/
class Accordion extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for accordion
+ * @param {Element | null} $root - HTML element to use for accordion
* @param {AccordionConfig} [config] - Accordion config
*/
- constructor($module, config = {}) {
- super($module);
- this.$module = void 0;
+ constructor($root, config = {}) {
+ super($root);
+ this.$root = void 0;
this.config = void 0;
this.i18n = void 0;
this.controlsClass = 'govuk-accordion__controls';
@@ -525,17 +525,17 @@ class Accordion extends GOVUKFrontendComponent {
this.$showAllButton = null;
this.$showAllIcon = null;
this.$showAllText = null;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Accordion',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- this.$module = $module;
- this.config = mergeConfigs(Accordion.defaults, config, normaliseDataset(Accordion, $module.dataset));
+ this.$root = $root;
+ this.config = mergeConfigs(Accordion.defaults, config, normaliseDataset(Accordion, $root.dataset));
this.i18n = new I18n(this.config.i18n);
- const $sections = this.$module.querySelectorAll(`.${this.sectionClass}`);
+ const $sections = this.$root.querySelectorAll(`.${this.sectionClass}`);
if (!$sections.length) {
throw new ElementError({
componentName: 'Accordion',
@@ -558,7 +558,7 @@ class Accordion extends GOVUKFrontendComponent {
const $accordionControls = document.createElement('div');
$accordionControls.setAttribute('class', this.controlsClass);
$accordionControls.appendChild(this.$showAllButton);
- this.$module.insertBefore($accordionControls, this.$module.firstChild);
+ this.$root.insertBefore($accordionControls, this.$root.firstChild);
this.$showAllText = document.createElement('span');
this.$showAllText.classList.add(this.showAllTextClass);
this.$showAllButton.appendChild(this.$showAllText);
@@ -600,7 +600,7 @@ class Accordion extends GOVUKFrontendComponent {
}
const $button = document.createElement('button');
$button.setAttribute('type', 'button');
- $button.setAttribute('aria-controls', `${this.$module.id}-content-${index + 1}`);
+ $button.setAttribute('aria-controls', `${this.$root.id}-content-${index + 1}`);
for (const attr of Array.from($span.attributes)) {
if (attr.name !== 'id') {
$button.setAttribute(attr.name, attr.value);
@@ -837,25 +837,25 @@ const DEBOUNCE_TIMEOUT_IN_SECONDS = 1;
*/
class Button extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for button
+ * @param {Element | null} $root - HTML element to use for button
* @param {ButtonConfig} [config] - Button config
*/
- constructor($module, config = {}) {
- super($module);
- this.$module = void 0;
+ constructor($root, config = {}) {
+ super($root);
+ this.$root = void 0;
this.config = void 0;
this.debounceFormSubmitTimer = null;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Button',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- this.$module = $module;
- this.config = mergeConfigs(Button.defaults, config, normaliseDataset(Button, $module.dataset));
- this.$module.addEventListener('keydown', event => this.handleKeyDown(event));
- this.$module.addEventListener('click', event => this.debounce(event));
+ this.$root = $root;
+ this.config = mergeConfigs(Button.defaults, config, normaliseDataset(Button, $root.dataset));
+ this.$root.addEventListener('keydown', event => this.handleKeyDown(event));
+ this.$root.addEventListener('click', event => this.debounce(event));
}
handleKeyDown(event) {
const $target = event.target;
@@ -923,13 +923,13 @@ function closestAttributeValue($element, attributeName) {
*/
class CharacterCount extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for character count
+ * @param {Element | null} $root - HTML element to use for character count
* @param {CharacterCountConfig} [config] - Character count config
*/
- constructor($module, config = {}) {
+ constructor($root, config = {}) {
var _ref, _this$config$maxwords;
- super($module);
- this.$module = void 0;
+ super($root);
+ this.$root = void 0;
this.$textarea = void 0;
this.$visibleCountMessage = void 0;
this.$screenReaderCountMessage = void 0;
@@ -939,14 +939,14 @@ class CharacterCount extends GOVUKFrontendComponent {
this.config = void 0;
this.i18n = void 0;
this.maxLength = void 0;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Character count',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- const $textarea = $module.querySelector('.govuk-js-character-count');
+ const $textarea = $root.querySelector('.govuk-js-character-count');
if (!($textarea instanceof HTMLTextAreaElement || $textarea instanceof HTMLInputElement)) {
throw new ElementError({
componentName: 'Character count',
@@ -955,7 +955,7 @@ class CharacterCount extends GOVUKFrontendComponent {
identifier: 'Form field (`.govuk-js-character-count`)'
});
}
- const datasetConfig = normaliseDataset(CharacterCount, $module.dataset);
+ const datasetConfig = normaliseDataset(CharacterCount, $root.dataset);
let configOverrides = {};
if ('maxwords' in datasetConfig || 'maxlength' in datasetConfig) {
configOverrides = {
@@ -969,10 +969,10 @@ class CharacterCount extends GOVUKFrontendComponent {
throw new ConfigError(`Character count: ${errors[0]}`);
}
this.i18n = new I18n(this.config.i18n, {
- locale: closestAttributeValue($module, 'lang')
+ locale: closestAttributeValue($root, 'lang')
});
this.maxLength = (_ref = (_this$config$maxwords = this.config.maxwords) != null ? _this$config$maxwords : this.config.maxlength) != null ? _ref : Infinity;
- this.$module = $module;
+ this.$root = $root;
this.$textarea = $textarea;
const textareaDescriptionId = `${this.$textarea.id}-info`;
const $textareaDescription = document.getElementById(textareaDescriptionId);
@@ -1222,27 +1222,27 @@ class Checkboxes extends GOVUKFrontendComponent {
* (for example if the user has navigated back), and set up event handlers to
* keep the reveal in sync with the checkbox state.
*
- * @param {Element | null} $module - HTML element to use for checkboxes
+ * @param {Element | null} $root - HTML element to use for checkboxes
*/
- constructor($module) {
- super($module);
- this.$module = void 0;
+ constructor($root) {
+ super($root);
+ this.$root = void 0;
this.$inputs = void 0;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Checkboxes',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- const $inputs = $module.querySelectorAll('input[type="checkbox"]');
+ const $inputs = $root.querySelectorAll('input[type="checkbox"]');
if (!$inputs.length) {
throw new ElementError({
componentName: 'Checkboxes',
identifier: 'Form inputs (`<input type="checkbox">`)'
});
}
- this.$module = $module;
+ this.$root = $root;
this.$inputs = $inputs;
this.$inputs.forEach($input => {
const targetId = $input.getAttribute('data-aria-controls');
@@ -1260,7 +1260,7 @@ class Checkboxes extends GOVUKFrontendComponent {
});
window.addEventListener('pageshow', () => this.syncAllConditionalReveals());
this.syncAllConditionalReveals();
- this.$module.addEventListener('click', event => this.handleClick(event));
+ this.$root.addEventListener('click', event => this.handleClick(event));
}
syncAllConditionalReveals() {
this.$inputs.forEach($input => this.syncConditionalRevealWithInputState($input));
@@ -1329,26 +1329,26 @@ Checkboxes.moduleName = 'govuk-checkboxes';
*/
class ErrorSummary extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for error summary
+ * @param {Element | null} $root - HTML element to use for error summary
* @param {ErrorSummaryConfig} [config] - Error summary config
*/
- constructor($module, config = {}) {
- super($module);
- this.$module = void 0;
+ constructor($root, config = {}) {
+ super($root);
+ this.$root = void 0;
this.config = void 0;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Error summary',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- this.$module = $module;
- this.config = mergeConfigs(ErrorSummary.defaults, config, normaliseDataset(ErrorSummary, $module.dataset));
+ this.$root = $root;
+ this.config = mergeConfigs(ErrorSummary.defaults, config, normaliseDataset(ErrorSummary, $root.dataset));
if (!this.config.disableAutoFocus) {
- setFocus(this.$module);
+ setFocus(this.$root);
}
- this.$module.addEventListener('click', event => this.handleClick(event));
+ this.$root.addEventListener('click', event => this.handleClick(event));
}
handleClick(event) {
const $target = event.target;
@@ -1432,12 +1432,12 @@ ErrorSummary.schema = Object.freeze({
*/
class ExitThisPage extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element that wraps the Exit This Page button
+ * @param {Element | null} $root - HTML element that wraps the Exit This Page button
* @param {ExitThisPageConfig} [config] - Exit This Page config
*/
- constructor($module, config = {}) {
- super($module);
- this.$module = void 0;
+ constructor($root, config = {}) {
+ super($root);
+ this.$root = void 0;
this.config = void 0;
this.i18n = void 0;
this.$button = void 0;
@@ -1450,14 +1450,14 @@ class ExitThisPage extends GOVUKFrontendComponent {
this.timeoutTime = 5000;
this.keypressTimeoutId = null;
this.timeoutMessageId = null;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Exit this page',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- const $button = $module.querySelector('.govuk-exit-this-page__button');
+ const $button = $root.querySelector('.govuk-exit-this-page__button');
if (!($button instanceof HTMLAnchorElement)) {
throw new ElementError({
componentName: 'Exit this page',
@@ -1466,9 +1466,9 @@ class ExitThisPage extends GOVUKFrontendComponent {
identifier: 'Button (`.govuk-exit-this-page__button`)'
});
}
- this.config = mergeConfigs(ExitThisPage.defaults, config, normaliseDataset(ExitThisPage, $module.dataset));
+ this.config = mergeConfigs(ExitThisPage.defaults, config, normaliseDataset(ExitThisPage, $root.dataset));
this.i18n = new I18n(this.config.i18n);
- this.$module = $module;
+ this.$root = $root;
this.$button = $button;
const $skiplinkButton = document.querySelector('.govuk-js-exit-this-page-skiplink');
if ($skiplinkButton instanceof HTMLAnchorElement) {
@@ -1487,7 +1487,7 @@ class ExitThisPage extends GOVUKFrontendComponent {
this.$updateSpan = document.createElement('span');
this.$updateSpan.setAttribute('role', 'status');
this.$updateSpan.className = 'govuk-visually-hidden';
- this.$module.appendChild(this.$updateSpan);
+ this.$root.appendChild(this.$updateSpan);
}
initButtonClickHandler() {
this.$button.addEventListener('click', this.handleClick.bind(this));
@@ -1662,24 +1662,24 @@ class Header extends GOVUKFrontendComponent {
* Apply a matchMedia for desktop which will trigger a state sync if the
* browser viewport moves between states.
*
- * @param {Element | null} $module - HTML element to use for header
+ * @param {Element | null} $root - HTML element to use for header
*/
- constructor($module) {
- super($module);
- this.$module = void 0;
+ constructor($root) {
+ super($root);
+ this.$root = void 0;
this.$menuButton = void 0;
this.$menu = void 0;
this.menuIsOpen = false;
this.mql = null;
- if (!$module) {
+ if (!$root) {
throw new ElementError({
componentName: 'Header',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- this.$module = $module;
- const $menuButton = $module.querySelector('.govuk-js-header-toggle');
+ this.$root = $root;
+ const $menuButton = $root.querySelector('.govuk-js-header-toggle');
if (!$menuButton) {
return this;
}
@@ -1750,24 +1750,24 @@ Header.moduleName = 'govuk-header';
*/
class NotificationBanner extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for notification banner
+ * @param {Element | null} $root - HTML element to use for notification banner
* @param {NotificationBannerConfig} [config] - Notification banner config
*/
- constructor($module, config = {}) {
- super($module);
- this.$module = void 0;
+ constructor($root, config = {}) {
+ super($root);
+ this.$root = void 0;
this.config = void 0;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Notification banner',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- this.$module = $module;
- this.config = mergeConfigs(NotificationBanner.defaults, config, normaliseDataset(NotificationBanner, $module.dataset));
- if (this.$module.getAttribute('role') === 'alert' && !this.config.disableAutoFocus) {
- setFocus(this.$module);
+ this.$root = $root;
+ this.config = mergeConfigs(NotificationBanner.defaults, config, normaliseDataset(NotificationBanner, $root.dataset));
+ if (this.$root.getAttribute('role') === 'alert' && !this.config.disableAutoFocus) {
+ setFocus(this.$root);
}
}
}
@@ -1804,25 +1804,25 @@ NotificationBanner.schema = Object.freeze({
*/
class PasswordInput extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for password input
+ * @param {Element | null} $root - HTML element to use for password input
* @param {PasswordInputConfig} [config] - Password input config
*/
- constructor($module, config = {}) {
+ constructor($root, config = {}) {
super();
- this.$module = void 0;
+ this.$root = void 0;
this.config = void 0;
this.i18n = void 0;
this.$input = void 0;
this.$showHideButton = void 0;
this.$screenReaderStatusMessage = void 0;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Password input',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- const $input = $module.querySelector('.govuk-js-password-input-input');
+ const $input = $root.querySelector('.govuk-js-password-input-input');
if (!($input instanceof HTMLInputElement)) {
throw new ElementError({
componentName: 'Password input',
@@ -1834,7 +1834,7 @@ class PasswordInput extends GOVUKFrontendComponent {
if ($input.type !== 'password') {
throw new ElementError('Password input: Form field (`.govuk-js-password-input-input`) must be of type `password`.');
}
- const $showHideButton = $module.querySelector('.govuk-js-password-input-toggle');
+ const $showHideButton = $root.querySelector('.govuk-js-password-input-toggle');
if (!($showHideButton instanceof HTMLButtonElement)) {
throw new ElementError({
componentName: 'Password input',
@@ -1846,12 +1846,12 @@ class PasswordInput extends GOVUKFrontendComponent {
if ($showHideButton.type !== 'button') {
throw new ElementError('Password input: Button (`.govuk-js-password-input-toggle`) must be of type `button`.');
}
- this.$module = $module;
+ this.$root = $root;
this.$input = $input;
this.$showHideButton = $showHideButton;
- this.config = mergeConfigs(PasswordInput.defaults, config, normaliseDataset(PasswordInput, $module.dataset));
+ this.config = mergeConfigs(PasswordInput.defaults, config, normaliseDataset(PasswordInput, $root.dataset));
this.i18n = new I18n(this.config.i18n, {
- locale: closestAttributeValue($module, 'lang')
+ locale: closestAttributeValue($root, 'lang')
});
this.$showHideButton.removeAttribute('hidden');
const $screenReaderStatusMessage = document.createElement('div');
@@ -1969,27 +1969,27 @@ class Radios extends GOVUKFrontendComponent {
* (for example if the user has navigated back), and set up event handlers to
* keep the reveal in sync with the radio state.
*
- * @param {Element | null} $module - HTML element to use for radios
+ * @param {Element | null} $root - HTML element to use for radios
*/
- constructor($module) {
- super($module);
- this.$module = void 0;
+ constructor($root) {
+ super($root);
+ this.$root = void 0;
this.$inputs = void 0;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Radios',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- const $inputs = $module.querySelectorAll('input[type="radio"]');
+ const $inputs = $root.querySelectorAll('input[type="radio"]');
if (!$inputs.length) {
throw new ElementError({
componentName: 'Radios',
identifier: 'Form inputs (`<input type="radio">`)'
});
}
- this.$module = $module;
+ this.$root = $root;
this.$inputs = $inputs;
this.$inputs.forEach($input => {
const targetId = $input.getAttribute('data-aria-controls');
@@ -2007,7 +2007,7 @@ class Radios extends GOVUKFrontendComponent {
});
window.addEventListener('pageshow', () => this.syncAllConditionalReveals());
this.syncAllConditionalReveals();
- this.$module.addEventListener('click', event => this.handleClick(event));
+ this.$root.addEventListener('click', event => this.handleClick(event));
}
syncAllConditionalReveals() {
this.$inputs.forEach($input => this.syncConditionalRevealWithInputState($input));
@@ -2050,24 +2050,24 @@ Radios.moduleName = 'govuk-radios';
*/
class ServiceNavigation extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for header
+ * @param {Element | null} $root - HTML element to use for header
*/
- constructor($module) {
+ constructor($root) {
super();
- this.$module = void 0;
+ this.$root = void 0;
this.$menuButton = void 0;
this.$menu = void 0;
this.menuIsOpen = false;
this.mql = null;
- if (!$module) {
+ if (!$root) {
throw new ElementError({
componentName: 'Service Navigation',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- this.$module = $module;
- const $menuButton = $module.querySelector('.govuk-js-service-navigation-toggle');
+ this.$root = $root;
+ const $menuButton = $root.querySelector('.govuk-js-service-navigation-toggle');
if (!$menuButton) {
return this;
}
@@ -2138,29 +2138,29 @@ ServiceNavigation.moduleName = 'govuk-service-navigation';
*/
class SkipLink extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for skip link
- * @throws {ElementError} when $module is not set or the wrong type
- * @throws {ElementError} when $module.hash does not contain a hash
+ * @param {Element | null} $root - HTML element to use for skip link
+ * @throws {ElementError} when $root is not set or the wrong type
+ * @throws {ElementError} when $root.hash does not contain a hash
* @throws {ElementError} when the linked element is missing or the wrong type
*/
- constructor($module) {
- var _this$$module$getAttr;
- super($module);
- this.$module = void 0;
- if (!($module instanceof HTMLAnchorElement)) {
+ constructor($root) {
+ var _this$$root$getAttrib;
+ super($root);
+ this.$root = void 0;
+ if (!($root instanceof HTMLAnchorElement)) {
throw new ElementError({
componentName: 'Skip link',
- element: $module,
+ element: $root,
expectedType: 'HTMLAnchorElement',
- identifier: 'Root element (`$module`)'
+ identifier: 'Root element (`$root`)'
});
}
- this.$module = $module;
- const hash = this.$module.hash;
- const href = (_this$$module$getAttr = this.$module.getAttribute('href')) != null ? _this$$module$getAttr : '';
+ this.$root = $root;
+ const hash = this.$root.hash;
+ const href = (_this$$root$getAttrib = this.$root.getAttribute('href')) != null ? _this$$root$getAttrib : '';
let url;
try {
- url = new window.URL(this.$module.href);
+ url = new window.URL(this.$root.href);
} catch (error) {
throw new ElementError(`Skip link: Target link (\`href="${href}"\`) is invalid`);
}
@@ -2179,7 +2179,7 @@ class SkipLink extends GOVUKFrontendComponent {
identifier: `Target content (\`id="${linkedElementId}"\`)`
});
}
- this.$module.addEventListener('click', () => setFocus($linkedElement, {
+ this.$root.addEventListener('click', () => setFocus($linkedElement, {
onBeforeFocus() {
$linkedElement.classList.add('govuk-skip-link-focused-element');
},
@@ -2198,11 +2198,11 @@ SkipLink.moduleName = 'govuk-skip-link';
*/
class Tabs extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for tabs
+ * @param {Element | null} $root - HTML element to use for tabs
*/
- constructor($module) {
- super($module);
- this.$module = void 0;
+ constructor($root) {
+ super($root);
+ this.$root = void 0;
this.$tabs = void 0;
this.$tabList = void 0;
this.$tabListItems = void 0;
@@ -2212,27 +2212,27 @@ class Tabs extends GOVUKFrontendComponent {
this.boundTabKeydown = void 0;
this.boundOnHashChange = void 0;
this.mql = null;
- if (!$module) {
+ if (!$root) {
throw new ElementError({
componentName: 'Tabs',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- const $tabs = $module.querySelectorAll('a.govuk-tabs__tab');
+ const $tabs = $root.querySelectorAll('a.govuk-tabs__tab');
if (!$tabs.length) {
throw new ElementError({
componentName: 'Tabs',
identifier: 'Links (`<a class="govuk-tabs__tab">`)'
});
}
- this.$module = $module;
+ this.$root = $root;
this.$tabs = $tabs;
this.boundTabClick = this.onTabClick.bind(this);
this.boundTabKeydown = this.onTabKeydown.bind(this);
this.boundOnHashChange = this.onHashChange.bind(this);
- const $tabList = this.$module.querySelector('.govuk-tabs__list');
- const $tabListItems = this.$module.querySelectorAll('li.govuk-tabs__list-item');
+ const $tabList = this.$root.querySelector('.govuk-tabs__list');
+ const $tabListItems = this.$root.querySelectorAll('li.govuk-tabs__list-item');
if (!$tabList) {
throw new ElementError({
componentName: 'Tabs',
@@ -2328,7 +2328,7 @@ class Tabs extends GOVUKFrontendComponent {
this.showPanel($tab);
}
getTab(hash) {
- return this.$module.querySelector(`a.govuk-tabs__tab[href="${hash}"]`);
+ return this.$root.querySelector(`a.govuk-tabs__tab[href="${hash}"]`);
}
setAttributes($tab) {
const panelId = getFragmentFromUrl($tab.href);
@@ -2439,7 +2439,7 @@ class Tabs extends GOVUKFrontendComponent {
if (!panelId) {
return null;
}
- return this.$module.querySelector(`#${panelId}`);
+ return this.$root.querySelector(`#${panelId}`);
}
showPanel($tab) {
const $panel = this.getPanel($tab);
@@ -2472,7 +2472,7 @@ class Tabs extends GOVUKFrontendComponent {
$tab.setAttribute('tabindex', '0');
}
getCurrentTab() {
- return this.$module.querySelector('.govuk-tabs__list-item--selected a.govuk-tabs__tab');
+ return this.$root.querySelector('.govuk-tabs__list-item--selected a.govuk-tabs__tab');
}
}
Tabs.moduleName = 'govuk-tabs';
diff --git a/packages/govuk-frontend/dist/govuk/common/index.mjs b/packages/govuk-frontend/dist/govuk/common/index.mjs
index e3aafbbb9..611e17a72 100644
--- a/packages/govuk-frontend/dist/govuk/common/index.mjs
+++ b/packages/govuk-frontend/dist/govuk/common/index.mjs
@@ -79,8 +79,8 @@ function setFocus($element, options = {}) {
(_options$onBeforeFocu = options.onBeforeFocus) == null || _options$onBeforeFocu.call($element);
$element.focus();
}
-function isInitialised($module, moduleName) {
- return $module instanceof HTMLElement && $module.hasAttribute(`data-${moduleName}-init`);
+function isInitialised($root, moduleName) {
+ return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
}
/**
diff --git a/packages/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.js b/packages/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.js
index 0b96e7125..ae38eb18a 100644
--- a/packages/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.js
+++ b/packages/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.js
@@ -74,8 +74,8 @@
}
return newObject[namespace];
}
- function isInitialised($module, moduleName) {
- return $module instanceof HTMLElement && $module.hasAttribute(`data-${moduleName}-init`);
+ function isInitialised($root, moduleName) {
+ return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
}
/**
@@ -175,7 +175,7 @@
constructor(moduleName, className) {
let errorText = `moduleName not defined in component (\`${className}\`)`;
if (typeof moduleName === 'string') {
- errorText = `Root element (\`$module\`) already initialised (\`${moduleName}\`)`;
+ errorText = `Root element (\`$root\`) already initialised (\`${moduleName}\`)`;
}
super(errorText);
this.name = 'InitError';
@@ -183,19 +183,19 @@
}
class GOVUKFrontendComponent {
- constructor($module) {
+ constructor($root) {
this.checkSupport();
- this.checkInitialised($module);
+ this.checkInitialised($root);
const moduleName = this.constructor.moduleName;
if (typeof moduleName === 'string') {
- moduleName && ($module == null ? void 0 : $module.setAttribute(`data-${moduleName}-init`, ''));
+ moduleName && ($root == null ? void 0 : $root.setAttribute(`data-${moduleName}-init`, ''));
} else {
throw new InitError(moduleName);
}
}
- checkInitialised($module) {
+ checkInitialised($root) {
const moduleName = this.constructor.moduleName;
- if ($module && moduleName && isInitialised($module, moduleName)) {
+ if ($root && moduleName && isInitialised($root, moduleName)) {
throw new InitError(moduleName);
}
}
@@ -434,12 +434,12 @@
*/
class Accordion extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for accordion
+ * @param {Element | null} $root - HTML element to use for accordion
* @param {AccordionConfig} [config] - Accordion config
*/
- constructor($module, config = {}) {
- super($module);
- this.$module = void 0;
+ constructor($root, config = {}) {
+ super($root);
+ this.$root = void 0;
this.config = void 0;
this.i18n = void 0;
this.controlsClass = 'govuk-accordion__controls';
@@ -465,17 +465,17 @@
this.$showAllButton = null;
this.$showAllIcon = null;
this.$showAllText = null;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Accordion',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- this.$module = $module;
- this.config = mergeConfigs(Accordion.defaults, config, normaliseDataset(Accordion, $module.dataset));
+ this.$root = $root;
+ this.config = mergeConfigs(Accordion.defaults, config, normaliseDataset(Accordion, $root.dataset));
this.i18n = new I18n(this.config.i18n);
- const $sections = this.$module.querySelectorAll(`.${this.sectionClass}`);
+ const $sections = this.$root.querySelectorAll(`.${this.sectionClass}`);
if (!$sections.length) {
throw new ElementError({
componentName: 'Accordion',
@@ -498,7 +498,7 @@
const $accordionControls = document.createElement('div');
$accordionControls.setAttribute('class', this.controlsClass);
$accordionControls.appendChild(this.$showAllButton);
- this.$module.insertBefore($accordionControls, this.$module.firstChild);
+ this.$root.insertBefore($accordionControls, this.$root.firstChild);
this.$showAllText = document.createElement('span');
this.$showAllText.classList.add(this.showAllTextClass);
this.$showAllButton.appendChild(this.$showAllText);
@@ -540,7 +540,7 @@
}
const $button = document.createElement('button');
$button.setAttribute('type', 'button');
- $button.setAttribute('aria-controls', `${this.$module.id}-content-${index + 1}`);
+ $button.setAttribute('aria-controls', `${this.$root.id}-content-${index + 1}`);
for (const attr of Array.from($span.attributes)) {
if (attr.name !== 'id') {
$button.setAttribute(attr.name, attr.value);
diff --git a/packages/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.mjs b/packages/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.mjs
index 4c4530f84..6f7fbd651 100644
--- a/packages/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.mjs
+++ b/packages/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.mjs
@@ -68,8 +68,8 @@ function extractConfigByNamespace(Component, dataset, namespace) {
}
return newObject[namespace];
}
-function isInitialised($module, moduleName) {
- return $module instanceof HTMLElement && $module.hasAttribute(`data-${moduleName}-init`);
+function isInitialised($root, moduleName) {
+ return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
}
/**
@@ -169,7 +169,7 @@ class InitError extends GOVUKFrontendError {
constructor(moduleName, className) {
let errorText = `moduleName not defined in component (\`${className}\`)`;
if (typeof moduleName === 'string') {
- errorText = `Root element (\`$module\`) already initialised (\`${moduleName}\`)`;
+ errorText = `Root element (\`$root\`) already initialised (\`${moduleName}\`)`;
}
super(errorText);
this.name = 'InitError';
@@ -177,19 +177,19 @@ class InitError extends GOVUKFrontendError {
}
class GOVUKFrontendComponent {
- constructor($module) {
+ constructor($root) {
this.checkSupport();
- this.checkInitialised($module);
+ this.checkInitialised($root);
const moduleName = this.constructor.moduleName;
if (typeof moduleName === 'string') {
- moduleName && ($module == null ? void 0 : $module.setAttribute(`data-${moduleName}-init`, ''));
+ moduleName && ($root == null ? void 0 : $root.setAttribute(`data-${moduleName}-init`, ''));
} else {
throw new InitError(moduleName);
}
}
- checkInitialised($module) {
+ checkInitialised($root) {
const moduleName = this.constructor.moduleName;
- if ($module && moduleName && isInitialised($module, moduleName)) {
+ if ($root && moduleName && isInitialised($root, moduleName)) {
throw new InitError(moduleName);
}
}
@@ -428,12 +428,12 @@ I18n.pluralRules = {
*/
class Accordion extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for accordion
+ * @param {Element | null} $root - HTML element to use for accordion
* @param {AccordionConfig} [config] - Accordion config
*/
- constructor($module, config = {}) {
- super($module);
- this.$module = void 0;
+ constructor($root, config = {}) {
+ super($root);
+ this.$root = void 0;
this.config = void 0;
this.i18n = void 0;
this.controlsClass = 'govuk-accordion__controls';
@@ -459,17 +459,17 @@ class Accordion extends GOVUKFrontendComponent {
this.$showAllButton = null;
this.$showAllIcon = null;
this.$showAllText = null;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Accordion',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- this.$module = $module;
- this.config = mergeConfigs(Accordion.defaults, config, normaliseDataset(Accordion, $module.dataset));
+ this.$root = $root;
+ this.config = mergeConfigs(Accordion.defaults, config, normaliseDataset(Accordion, $root.dataset));
this.i18n = new I18n(this.config.i18n);
- const $sections = this.$module.querySelectorAll(`.${this.sectionClass}`);
+ const $sections = this.$root.querySelectorAll(`.${this.sectionClass}`);
if (!$sections.length) {
throw new ElementError({
componentName: 'Accordion',
@@ -492,7 +492,7 @@ class Accordion extends GOVUKFrontendComponent {
const $accordionControls = document.createElement('div');
$accordionControls.setAttribute('class', this.controlsClass);
$accordionControls.appendChild(this.$showAllButton);
- this.$module.insertBefore($accordionControls, this.$module.firstChild);
+ this.$root.insertBefore($accordionControls, this.$root.firstChild);
this.$showAllText = document.createElement('span');
this.$showAllText.classList.add(this.showAllTextClass);
this.$showAllButton.appendChild(this.$showAllText);
@@ -534,7 +534,7 @@ class Accordion extends GOVUKFrontendComponent {
}
const $button = document.createElement('button');
$button.setAttribute('type', 'button');
- $button.setAttribute('aria-controls', `${this.$module.id}-content-${index + 1}`);
+ $button.setAttribute('aria-controls', `${this.$root.id}-content-${index + 1}`);
for (const attr of Array.from($span.attributes)) {
if (attr.name !== 'id') {
$button.setAttribute(attr.name, attr.value);
diff --git a/packages/govuk-frontend/dist/govuk/components/accordion/accordion.mjs b/packages/govuk-frontend/dist/govuk/components/accordion/accordion.mjs
index 31a0ee243..ed6ee4c3f 100644
--- a/packages/govuk-frontend/dist/govuk/components/accordion/accordion.mjs
+++ b/packages/govuk-frontend/dist/govuk/components/accordion/accordion.mjs
@@ -20,12 +20,12 @@ import { I18n } from '../../i18n.mjs';
*/
class Accordion extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for accordion
+ * @param {Element | null} $root - HTML element to use for accordion
* @param {AccordionConfig} [config] - Accordion config
*/
- constructor($module, config = {}) {
- super($module);
- this.$module = void 0;
+ constructor($root, config = {}) {
+ super($root);
+ this.$root = void 0;
this.config = void 0;
this.i18n = void 0;
this.controlsClass = 'govuk-accordion__controls';
@@ -51,17 +51,17 @@ class Accordion extends GOVUKFrontendComponent {
this.$showAllButton = null;
this.$showAllIcon = null;
this.$showAllText = null;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Accordion',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- this.$module = $module;
- this.config = mergeConfigs(Accordion.defaults, config, normaliseDataset(Accordion, $module.dataset));
+ this.$root = $root;
+ this.config = mergeConfigs(Accordion.defaults, config, normaliseDataset(Accordion, $root.dataset));
this.i18n = new I18n(this.config.i18n);
- const $sections = this.$module.querySelectorAll(`.${this.sectionClass}`);
+ const $sections = this.$root.querySelectorAll(`.${this.sectionClass}`);
if (!$sections.length) {
throw new ElementError({
componentName: 'Accordion',
@@ -84,7 +84,7 @@ class Accordion extends GOVUKFrontendComponent {
const $accordionControls = document.createElement('div');
$accordionControls.setAttribute('class', this.controlsClass);
$accordionControls.appendChild(this.$showAllButton);
- this.$module.insertBefore($accordionControls, this.$module.firstChild);
+ this.$root.insertBefore($accordionControls, this.$root.firstChild);
this.$showAllText = document.createElement('span');
this.$showAllText.classList.add(this.showAllTextClass);
this.$showAllButton.appendChild(this.$showAllText);
@@ -126,7 +126,7 @@ class Accordion extends GOVUKFrontendComponent {
}
const $button = document.createElement('button');
$button.setAttribute('type', 'button');
- $button.setAttribute('aria-controls', `${this.$module.id}-content-${index + 1}`);
+ $button.setAttribute('aria-controls', `${this.$root.id}-content-${index + 1}`);
for (const attr of Array.from($span.attributes)) {
if (attr.name !== 'id') {
$button.setAttribute(attr.name, attr.value);
diff --git a/packages/govuk-frontend/dist/govuk/components/button/button.bundle.js b/packages/govuk-frontend/dist/govuk/components/button/button.bundle.js
index 07424eb65..555919276 100644
--- a/packages/govuk-frontend/dist/govuk/components/button/button.bundle.js
+++ b/packages/govuk-frontend/dist/govuk/components/button/button.bundle.js
@@ -74,8 +74,8 @@
}
return newObject[namespace];
}
- function isInitialised($module, moduleName) {
- return $module instanceof HTMLElement && $module.hasAttribute(`data-${moduleName}-init`);
+ function isInitialised($root, moduleName) {
+ return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
}
/**
@@ -175,7 +175,7 @@
constructor(moduleName, className) {
let errorText = `moduleName not defined in component (\`${className}\`)`;
if (typeof moduleName === 'string') {
- errorText = `Root element (\`$module\`) already initialised (\`${moduleName}\`)`;
+ errorText = `Root element (\`$root\`) already initialised (\`${moduleName}\`)`;
}
super(errorText);
this.name = 'InitError';
@@ -183,19 +183,19 @@
}
class GOVUKFrontendComponent {
- constructor($module) {
+ constructor($root) {
this.checkSupport();
- this.checkInitialised($module);
+ this.checkInitialised($root);
const moduleName = this.constructor.moduleName;
if (typeof moduleName === 'string') {
- moduleName && ($module == null ? void 0 : $module.setAttribute(`data-${moduleName}-init`, ''));
+ moduleName && ($root == null ? void 0 : $root.setAttribute(`data-${moduleName}-init`, ''));
} else {
throw new InitError(moduleName);
}
}
- checkInitialised($module) {
+ checkInitialised($root) {
const moduleName = this.constructor.moduleName;
- if ($module && moduleName && isInitialised($module, moduleName)) {
+ if ($root && moduleName && isInitialised($root, moduleName)) {
throw new InitError(moduleName);
}
}
@@ -234,25 +234,25 @@
*/
class Button extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for button
+ * @param {Element | null} $root - HTML element to use for button
* @param {ButtonConfig} [config] - Button config
*/
- constructor($module, config = {}) {
- super($module);
- this.$module = void 0;
+ constructor($root, config = {}) {
+ super($root);
+ this.$root = void 0;
this.config = void 0;
this.debounceFormSubmitTimer = null;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Button',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- this.$module = $module;
- this.config = mergeConfigs(Button.defaults, config, normaliseDataset(Button, $module.dataset));
- this.$module.addEventListener('keydown', event => this.handleKeyDown(event));
- this.$module.addEventListener('click', event => this.debounce(event));
+ this.$root = $root;
+ this.config = mergeConfigs(Button.defaults, config, normaliseDataset(Button, $root.dataset));
+ this.$root.addEventListener('keydown', event => this.handleKeyDown(event));
+ this.$root.addEventListener('click', event => this.debounce(event));
}
handleKeyDown(event) {
const $target = event.target;
diff --git a/packages/govuk-frontend/dist/govuk/components/button/button.bundle.mjs b/packages/govuk-frontend/dist/govuk/components/button/button.bundle.mjs
index d9412f41d..3042a3321 100644
--- a/packages/govuk-frontend/dist/govuk/components/button/button.bundle.mjs
+++ b/packages/govuk-frontend/dist/govuk/components/button/button.bundle.mjs
@@ -68,8 +68,8 @@ function extractConfigByNamespace(Component, dataset, namespace) {
}
return newObject[namespace];
}
-function isInitialised($module, moduleName) {
- return $module instanceof HTMLElement && $module.hasAttribute(`data-${moduleName}-init`);
+function isInitialised($root, moduleName) {
+ return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
}
/**
@@ -169,7 +169,7 @@ class InitError extends GOVUKFrontendError {
constructor(moduleName, className) {
let errorText = `moduleName not defined in component (\`${className}\`)`;
if (typeof moduleName === 'string') {
- errorText = `Root element (\`$module\`) already initialised (\`${moduleName}\`)`;
+ errorText = `Root element (\`$root\`) already initialised (\`${moduleName}\`)`;
}
super(errorText);
this.name = 'InitError';
@@ -177,19 +177,19 @@ class InitError extends GOVUKFrontendError {
}
class GOVUKFrontendComponent {
- constructor($module) {
+ constructor($root) {
this.checkSupport();
- this.checkInitialised($module);
+ this.checkInitialised($root);
const moduleName = this.constructor.moduleName;
if (typeof moduleName === 'string') {
- moduleName && ($module == null ? void 0 : $module.setAttribute(`data-${moduleName}-init`, ''));
+ moduleName && ($root == null ? void 0 : $root.setAttribute(`data-${moduleName}-init`, ''));
} else {
throw new InitError(moduleName);
}
}
- checkInitialised($module) {
+ checkInitialised($root) {
const moduleName = this.constructor.moduleName;
- if ($module && moduleName && isInitialised($module, moduleName)) {
+ if ($root && moduleName && isInitialised($root, moduleName)) {
throw new InitError(moduleName);
}
}
@@ -228,25 +228,25 @@ const DEBOUNCE_TIMEOUT_IN_SECONDS = 1;
*/
class Button extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for button
+ * @param {Element | null} $root - HTML element to use for button
* @param {ButtonConfig} [config] - Button config
*/
- constructor($module, config = {}) {
- super($module);
- this.$module = void 0;
+ constructor($root, config = {}) {
+ super($root);
+ this.$root = void 0;
this.config = void 0;
this.debounceFormSubmitTimer = null;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Button',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- this.$module = $module;
- this.config = mergeConfigs(Button.defaults, config, normaliseDataset(Button, $module.dataset));
- this.$module.addEventListener('keydown', event => this.handleKeyDown(event));
- this.$module.addEventListener('click', event => this.debounce(event));
+ this.$root = $root;
+ this.config = mergeConfigs(Button.defaults, config, normaliseDataset(Button, $root.dataset));
+ this.$root.addEventListener('keydown', event => this.handleKeyDown(event));
+ this.$root.addEventListener('click', event => this.debounce(event));
}
handleKeyDown(event) {
const $target = event.target;
diff --git a/packages/govuk-frontend/dist/govuk/components/button/button.mjs b/packages/govuk-frontend/dist/govuk/components/button/button.mjs
index 270e90a7a..792e7e948 100644
--- a/packages/govuk-frontend/dist/govuk/components/button/button.mjs
+++ b/packages/govuk-frontend/dist/govuk/components/button/button.mjs
@@ -12,25 +12,25 @@ const DEBOUNCE_TIMEOUT_IN_SECONDS = 1;
*/
class Button extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for button
+ * @param {Element | null} $root - HTML element to use for button
* @param {ButtonConfig} [config] - Button config
*/
- constructor($module, config = {}) {
- super($module);
- this.$module = void 0;
+ constructor($root, config = {}) {
+ super($root);
+ this.$root = void 0;
this.config = void 0;
this.debounceFormSubmitTimer = null;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Button',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- this.$module = $module;
- this.config = mergeConfigs(Button.defaults, config, normaliseDataset(Button, $module.dataset));
- this.$module.addEventListener('keydown', event => this.handleKeyDown(event));
- this.$module.addEventListener('click', event => this.debounce(event));
+ this.$root = $root;
+ this.config = mergeConfigs(Button.defaults, config, normaliseDataset(Button, $root.dataset));
+ this.$root.addEventListener('keydown', event => this.handleKeyDown(event));
+ this.$root.addEventListener('click', event => this.debounce(event));
}
handleKeyDown(event) {
const $target = event.target;
diff --git a/packages/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.js b/packages/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.js
index 76ce4eea5..2663df4f7 100644
--- a/packages/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.js
+++ b/packages/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.js
@@ -79,8 +79,8 @@
}
return newObject[namespace];
}
- function isInitialised($module, moduleName) {
- return $module instanceof HTMLElement && $module.hasAttribute(`data-${moduleName}-init`);
+ function isInitialised($root, moduleName) {
+ return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
}
/**
@@ -206,7 +206,7 @@
constructor(moduleName, className) {
let errorText = `moduleName not defined in component (\`${className}\`)`;
if (typeof moduleName === 'string') {
- errorText = `Root element (\`$module\`) already initialised (\`${moduleName}\`)`;
+ errorText = `Root element (\`$root\`) already initialised (\`${moduleName}\`)`;
}
super(errorText);
this.name = 'InitError';
@@ -214,19 +214,19 @@
}
class GOVUKFrontendComponent {
- constructor($module) {
+ constructor($root) {
this.checkSupport();
- this.checkInitialised($module);
+ this.checkInitialised($root);
const moduleName = this.constructor.moduleName;
if (typeof moduleName === 'string') {
- moduleName && ($module == null ? void 0 : $module.setAttribute(`data-${moduleName}-init`, ''));
+ moduleName && ($root == null ? void 0 : $root.setAttribute(`data-${moduleName}-init`, ''));
} else {
throw new InitError(moduleName);
}
}
- checkInitialised($module) {
+ checkInitialised($root) {
const moduleName = this.constructor.moduleName;
- if ($module && moduleName && isInitialised($module, moduleName)) {
+ if ($root && moduleName && isInitialised($root, moduleName)) {
throw new InitError(moduleName);
}
}
@@ -463,13 +463,13 @@
*/
class CharacterCount extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for character count
+ * @param {Element | null} $root - HTML element to use for character count
* @param {CharacterCountConfig} [config] - Character count config
*/
- constructor($module, config = {}) {
+ constructor($root, config = {}) {
var _ref, _this$config$maxwords;
- super($module);
- this.$module = void 0;
+ super($root);
+ this.$root = void 0;
this.$textarea = void 0;
this.$visibleCountMessage = void 0;
this.$screenReaderCountMessage = void 0;
@@ -479,14 +479,14 @@
this.config = void 0;
this.i18n = void 0;
this.maxLength = void 0;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Character count',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- const $textarea = $module.querySelector('.govuk-js-character-count');
+ const $textarea = $root.querySelector('.govuk-js-character-count');
if (!($textarea instanceof HTMLTextAreaElement || $textarea instanceof HTMLInputElement)) {
throw new ElementError({
componentName: 'Character count',
@@ -495,7 +495,7 @@
identifier: 'Form field (`.govuk-js-character-count`)'
});
}
- const datasetConfig = normaliseDataset(CharacterCount, $module.dataset);
+ const datasetConfig = normaliseDataset(CharacterCount, $root.dataset);
let configOverrides = {};
if ('maxwords' in datasetConfig || 'maxlength' in datasetConfig) {
configOverrides = {
@@ -509,10 +509,10 @@
throw new ConfigError(`Character count: ${errors[0]}`);
}
this.i18n = new I18n(this.config.i18n, {
- locale: closestAttributeValue($module, 'lang')
+ locale: closestAttributeValue($root, 'lang')
});
this.maxLength = (_ref = (_this$config$maxwords = this.config.maxwords) != null ? _this$config$maxwords : this.config.maxlength) != null ? _ref : Infinity;
- this.$module = $module;
+ this.$root = $root;
this.$textarea = $textarea;
const textareaDescriptionId = `${this.$textarea.id}-info`;
const $textareaDescription = document.getElementById(textareaDescriptionId);
diff --git a/packages/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.mjs b/packages/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.mjs
index 34ee63460..1adf9e9f9 100644
--- a/packages/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.mjs
+++ b/packages/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.mjs
@@ -73,8 +73,8 @@ function extractConfigByNamespace(Component, dataset, namespace) {
}
return newObject[namespace];
}
-function isInitialised($module, moduleName) {
- return $module instanceof HTMLElement && $module.hasAttribute(`data-${moduleName}-init`);
+function isInitialised($root, moduleName) {
+ return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
}
/**
@@ -200,7 +200,7 @@ class InitError extends GOVUKFrontendError {
constructor(moduleName, className) {
let errorText = `moduleName not defined in component (\`${className}\`)`;
if (typeof moduleName === 'string') {
- errorText = `Root element (\`$module\`) already initialised (\`${moduleName}\`)`;
+ errorText = `Root element (\`$root\`) already initialised (\`${moduleName}\`)`;
}
super(errorText);
this.name = 'InitError';
@@ -208,19 +208,19 @@ class InitError extends GOVUKFrontendError {
}
class GOVUKFrontendComponent {
- constructor($module) {
+ constructor($root) {
this.checkSupport();
- this.checkInitialised($module);
+ this.checkInitialised($root);
const moduleName = this.constructor.moduleName;
if (typeof moduleName === 'string') {
- moduleName && ($module == null ? void 0 : $module.setAttribute(`data-${moduleName}-init`, ''));
+ moduleName && ($root == null ? void 0 : $root.setAttribute(`data-${moduleName}-init`, ''));
} else {
throw new InitError(moduleName);
}
}
- checkInitialised($module) {
+ checkInitialised($root) {
const moduleName = this.constructor.moduleName;
- if ($module && moduleName && isInitialised($module, moduleName)) {
+ if ($root && moduleName && isInitialised($root, moduleName)) {
throw new InitError(moduleName);
}
}
@@ -457,13 +457,13 @@ I18n.pluralRules = {
*/
class CharacterCount extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for character count
+ * @param {Element | null} $root - HTML element to use for character count
* @param {CharacterCountConfig} [config] - Character count config
*/
- constructor($module, config = {}) {
+ constructor($root, config = {}) {
var _ref, _this$config$maxwords;
- super($module);
- this.$module = void 0;
+ super($root);
+ this.$root = void 0;
this.$textarea = void 0;
this.$visibleCountMessage = void 0;
this.$screenReaderCountMessage = void 0;
@@ -473,14 +473,14 @@ class CharacterCount extends GOVUKFrontendComponent {
this.config = void 0;
this.i18n = void 0;
this.maxLength = void 0;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Character count',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- const $textarea = $module.querySelector('.govuk-js-character-count');
+ const $textarea = $root.querySelector('.govuk-js-character-count');
if (!($textarea instanceof HTMLTextAreaElement || $textarea instanceof HTMLInputElement)) {
throw new ElementError({
componentName: 'Character count',
@@ -489,7 +489,7 @@ class CharacterCount extends GOVUKFrontendComponent {
identifier: 'Form field (`.govuk-js-character-count`)'
});
}
- const datasetConfig = normaliseDataset(CharacterCount, $module.dataset);
+ const datasetConfig = normaliseDataset(CharacterCount, $root.dataset);
let configOverrides = {};
if ('maxwords' in datasetConfig || 'maxlength' in datasetConfig) {
configOverrides = {
@@ -503,10 +503,10 @@ class CharacterCount extends GOVUKFrontendComponent {
throw new ConfigError(`Character count: ${errors[0]}`);
}
this.i18n = new I18n(this.config.i18n, {
- locale: closestAttributeValue($module, 'lang')
+ locale: closestAttributeValue($root, 'lang')
});
this.maxLength = (_ref = (_this$config$maxwords = this.config.maxwords) != null ? _this$config$maxwords : this.config.maxlength) != null ? _ref : Infinity;
- this.$module = $module;
+ this.$root = $root;
this.$textarea = $textarea;
const textareaDescriptionId = `${this.$textarea.id}-info`;
const $textareaDescription = document.getElementById(textareaDescriptionId);
diff --git a/packages/govuk-frontend/dist/govuk/components/character-count/character-count.mjs b/packages/govuk-frontend/dist/govuk/components/character-count/character-count.mjs
index 7ab241064..fe457353b 100644
--- a/packages/govuk-frontend/dist/govuk/components/character-count/character-count.mjs
+++ b/packages/govuk-frontend/dist/govuk/components/character-count/character-count.mjs
@@ -19,13 +19,13 @@ import { I18n } from '../../i18n.mjs';
*/
class CharacterCount extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for character count
+ * @param {Element | null} $root - HTML element to use for character count
* @param {CharacterCountConfig} [config] - Character count config
*/
- constructor($module, config = {}) {
+ constructor($root, config = {}) {
var _ref, _this$config$maxwords;
- super($module);
- this.$module = void 0;
+ super($root);
+ this.$root = void 0;
this.$textarea = void 0;
this.$visibleCountMessage = void 0;
this.$screenReaderCountMessage = void 0;
@@ -35,14 +35,14 @@ class CharacterCount extends GOVUKFrontendComponent {
this.config = void 0;
this.i18n = void 0;
this.maxLength = void 0;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Character count',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- const $textarea = $module.querySelector('.govuk-js-character-count');
+ const $textarea = $root.querySelector('.govuk-js-character-count');
if (!($textarea instanceof HTMLTextAreaElement || $textarea instanceof HTMLInputElement)) {
throw new ElementError({
componentName: 'Character count',
@@ -51,7 +51,7 @@ class CharacterCount extends GOVUKFrontendComponent {
identifier: 'Form field (`.govuk-js-character-count`)'
});
}
- const datasetConfig = normaliseDataset(CharacterCount, $module.dataset);
+ const datasetConfig = normaliseDataset(CharacterCount, $root.dataset);
let configOverrides = {};
if ('maxwords' in datasetConfig || 'maxlength' in datasetConfig) {
configOverrides = {
@@ -65,10 +65,10 @@ class CharacterCount extends GOVUKFrontendComponent {
throw new ConfigError(`Character count: ${errors[0]}`);
}
this.i18n = new I18n(this.config.i18n, {
- locale: closestAttributeValue($module, 'lang')
+ locale: closestAttributeValue($root, 'lang')
});
this.maxLength = (_ref = (_this$config$maxwords = this.config.maxwords) != null ? _this$config$maxwords : this.config.maxlength) != null ? _ref : Infinity;
- this.$module = $module;
+ this.$root = $root;
this.$textarea = $textarea;
const textareaDescriptionId = `${this.$textarea.id}-info`;
const $textareaDescription = document.getElementById(textareaDescriptionId);
diff --git a/packages/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.js b/packages/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.js
index b77f9b743..bc7bf0eaa 100644
--- a/packages/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.js
+++ b/packages/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.js
@@ -43,15 +43,15 @@
constructor(moduleName, className) {
let errorText = `moduleName not defined in component (\`${className}\`)`;
if (typeof moduleName === 'string') {
- errorText = `Root element (\`$module\`) already initialised (\`${moduleName}\`)`;
+ errorText = `Root element (\`$root\`) already initialised (\`${moduleName}\`)`;
}
super(errorText);
this.name = 'InitError';
}
}
- function isInitialised($module, moduleName) {
- return $module instanceof HTMLElement && $module.hasAttribute(`data-${moduleName}-init`);
+ function isInitialised($root, moduleName) {
+ return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
}
/**
@@ -94,19 +94,19 @@
*/
class GOVUKFrontendComponent {
- constructor($module) {
+ constructor($root) {
this.checkSupport();
- this.checkInitialised($module);
+ this.checkInitialised($root);
const moduleName = this.constructor.moduleName;
if (typeof moduleName === 'string') {
- moduleName && ($module == null ? void 0 : $module.setAttribute(`data-${moduleName}-init`, ''));
+ moduleName && ($root == null ? void 0 : $root.setAttribute(`data-${moduleName}-init`, ''));
} else {
throw new InitError(moduleName);
}
}
- checkInitialised($module) {
+ checkInitialised($root) {
const moduleName = this.constructor.moduleName;
- if ($module && moduleName && isInitialised($module, moduleName)) {
+ if ($root && moduleName && isInitialised($root, moduleName)) {
throw new InitError(moduleName);
}
}
@@ -154,27 +154,27 @@
* (for example if the user has navigated back), and set up event handlers to
* keep the reveal in sync with the checkbox state.
*
- * @param {Element | null} $module - HTML element to use for checkboxes
+ * @param {Element | null} $root - HTML element to use for checkboxes
*/
- constructor($module) {
- super($module);
- this.$module = void 0;
+ constructor($root) {
+ super($root);
+ this.$root = void 0;
this.$inputs = void 0;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Checkboxes',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- const $inputs = $module.querySelectorAll('input[type="checkbox"]');
+ const $inputs = $root.querySelectorAll('input[type="checkbox"]');
if (!$inputs.length) {
throw new ElementError({
componentName: 'Checkboxes',
identifier: 'Form inputs (`<input type="checkbox">`)'
});
}
- this.$module = $module;
+ this.$root = $root;
this.$inputs = $inputs;
this.$inputs.forEach($input => {
const targetId = $input.getAttribute('data-aria-controls');
@@ -192,7 +192,7 @@
});
window.addEventListener('pageshow', () => this.syncAllConditionalReveals());
this.syncAllConditionalReveals();
- this.$module.addEventListener('click', event => this.handleClick(event));
+ this.$root.addEventListener('click', event => this.handleClick(event));
}
syncAllConditionalReveals() {
this.$inputs.forEach($input => this.syncConditionalRevealWithInputState($input));
diff --git a/packages/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.mjs b/packages/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.mjs
index e3c1fd925..06ddb0c14 100644
--- a/packages/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.mjs
+++ b/packages/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.mjs
@@ -37,15 +37,15 @@ class InitError extends GOVUKFrontendError {
constructor(moduleName, className) {
let errorText = `moduleName not defined in component (\`${className}\`)`;
if (typeof moduleName === 'string') {
- errorText = `Root element (\`$module\`) already initialised (\`${moduleName}\`)`;
+ errorText = `Root element (\`$root\`) already initialised (\`${moduleName}\`)`;
}
super(errorText);
this.name = 'InitError';
}
}
-function isInitialised($module, moduleName) {
- return $module instanceof HTMLElement && $module.hasAttribute(`data-${moduleName}-init`);
+function isInitialised($root, moduleName) {
+ return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
}
/**
@@ -88,19 +88,19 @@ function isSupported($scope = document.body) {
*/
class GOVUKFrontendComponent {
- constructor($module) {
+ constructor($root) {
this.checkSupport();
- this.checkInitialised($module);
+ this.checkInitialised($root);
const moduleName = this.constructor.moduleName;
if (typeof moduleName === 'string') {
- moduleName && ($module == null ? void 0 : $module.setAttribute(`data-${moduleName}-init`, ''));
+ moduleName && ($root == null ? void 0 : $root.setAttribute(`data-${moduleName}-init`, ''));
} else {
throw new InitError(moduleName);
}
}
- checkInitialised($module) {
+ checkInitialised($root) {
const moduleName = this.constructor.moduleName;
- if ($module && moduleName && isInitialised($module, moduleName)) {
+ if ($root && moduleName && isInitialised($root, moduleName)) {
throw new InitError(moduleName);
}
}
@@ -148,27 +148,27 @@ class Checkboxes extends GOVUKFrontendComponent {
* (for example if the user has navigated back), and set up event handlers to
* keep the reveal in sync with the checkbox state.
*
- * @param {Element | null} $module - HTML element to use for checkboxes
+ * @param {Element | null} $root - HTML element to use for checkboxes
*/
- constructor($module) {
- super($module);
- this.$module = void 0;
+ constructor($root) {
+ super($root);
+ this.$root = void 0;
this.$inputs = void 0;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Checkboxes',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- const $inputs = $module.querySelectorAll('input[type="checkbox"]');
+ const $inputs = $root.querySelectorAll('input[type="checkbox"]');
if (!$inputs.length) {
throw new ElementError({
componentName: 'Checkboxes',
identifier: 'Form inputs (`<input type="checkbox">`)'
});
}
- this.$module = $module;
+ this.$root = $root;
this.$inputs = $inputs;
this.$inputs.forEach($input => {
const targetId = $input.getAttribute('data-aria-controls');
@@ -186,7 +186,7 @@ class Checkboxes extends GOVUKFrontendComponent {
});
window.addEventListener('pageshow', () => this.syncAllConditionalReveals());
this.syncAllConditionalReveals();
- this.$module.addEventListener('click', event => this.handleClick(event));
+ this.$root.addEventListener('click', event => this.handleClick(event));
}
syncAllConditionalReveals() {
this.$inputs.forEach($input => this.syncConditionalRevealWithInputState($input));
diff --git a/packages/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.mjs b/packages/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.mjs
index 5f34b5a12..13f7cab03 100644
--- a/packages/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.mjs
+++ b/packages/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.mjs
@@ -19,27 +19,27 @@ class Checkboxes extends GOVUKFrontendComponent {
* (for example if the user has navigated back), and set up event handlers to
* keep the reveal in sync with the checkbox state.
*
- * @param {Element | null} $module - HTML element to use for checkboxes
+ * @param {Element | null} $root - HTML element to use for checkboxes
*/
- constructor($module) {
- super($module);
- this.$module = void 0;
+ constructor($root) {
+ super($root);
+ this.$root = void 0;
this.$inputs = void 0;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Checkboxes',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- const $inputs = $module.querySelectorAll('input[type="checkbox"]');
+ const $inputs = $root.querySelectorAll('input[type="checkbox"]');
if (!$inputs.length) {
throw new ElementError({
componentName: 'Checkboxes',
identifier: 'Form inputs (`<input type="checkbox">`)'
});
}
- this.$module = $module;
+ this.$root = $root;
this.$inputs = $inputs;
this.$inputs.forEach($input => {
const targetId = $input.getAttribute('data-aria-controls');
@@ -57,7 +57,7 @@ class Checkboxes extends GOVUKFrontendComponent {
});
window.addEventListener('pageshow', () => this.syncAllConditionalReveals());
this.syncAllConditionalReveals();
- this.$module.addEventListener('click', event => this.handleClick(event));
+ this.$root.addEventListener('click', event => this.handleClick(event));
}
syncAllConditionalReveals() {
this.$inputs.forEach($input => this.syncConditionalRevealWithInputState($input));
diff --git a/packages/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.js b/packages/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.js
index 99c71b5ff..411671b47 100644
--- a/packages/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.js
+++ b/packages/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.js
@@ -104,8 +104,8 @@
(_options$onBeforeFocu = options.onBeforeFocus) == null || _options$onBeforeFocu.call($element);
$element.focus();
}
- function isInitialised($module, moduleName) {
- return $module instanceof HTMLElement && $module.hasAttribute(`data-${moduleName}-init`);
+ function isInitialised($root, moduleName) {
+ return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
}
/**
@@ -205,7 +205,7 @@
constructor(moduleName, className) {
let errorText = `moduleName not defined in component (\`${className}\`)`;
if (typeof moduleName === 'string') {
- errorText = `Root element (\`$module\`) already initialised (\`${moduleName}\`)`;
+ errorText = `Root element (\`$root\`) already initialised (\`${moduleName}\`)`;
}
super(errorText);
this.name = 'InitError';
@@ -213,19 +213,19 @@
}
class GOVUKFrontendComponent {
- constructor($module) {
+ constructor($root) {
this.checkSupport();
- this.checkInitialised($module);
+ this.checkInitialised($root);
const moduleName = this.constructor.moduleName;
if (typeof moduleName === 'string') {
- moduleName && ($module == null ? void 0 : $module.setAttribute(`data-${moduleName}-init`, ''));
+ moduleName && ($root == null ? void 0 : $root.setAttribute(`data-${moduleName}-init`, ''));
} else {
throw new InitError(moduleName);
}
}
- checkInitialised($module) {
+ checkInitialised($root) {
const moduleName = this.constructor.moduleName;
- if ($module && moduleName && isInitialised($module, moduleName)) {
+ if ($root && moduleName && isInitialised($root, moduleName)) {
throw new InitError(moduleName);
}
}
@@ -265,26 +265,26 @@
*/
class ErrorSummary extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for error summary
+ * @param {Element | null} $root - HTML element to use for error summary
* @param {ErrorSummaryConfig} [config] - Error summary config
*/
- constructor($module, config = {}) {
- super($module);
- this.$module = void 0;
+ constructor($root, config = {}) {
+ super($root);
+ this.$root = void 0;
this.config = void 0;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Error summary',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- this.$module = $module;
- this.config = mergeConfigs(ErrorSummary.defaults, config, normaliseDataset(ErrorSummary, $module.dataset));
+ this.$root = $root;
+ this.config = mergeConfigs(ErrorSummary.defaults, config, normaliseDataset(ErrorSummary, $root.dataset));
if (!this.config.disableAutoFocus) {
- setFocus(this.$module);
+ setFocus(this.$root);
}
- this.$module.addEventListener('click', event => this.handleClick(event));
+ this.$root.addEventListener('click', event => this.handleClick(event));
}
handleClick(event) {
const $target = event.target;
diff --git a/packages/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.mjs b/packages/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.mjs
index 8600154f1..832a9b099 100644
--- a/packages/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.mjs
+++ b/packages/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.mjs
@@ -98,8 +98,8 @@ function setFocus($element, options = {}) {
(_options$onBeforeFocu = options.onBeforeFocus) == null || _options$onBeforeFocu.call($element);
$element.focus();
}
-function isInitialised($module, moduleName) {
- return $module instanceof HTMLElement && $module.hasAttribute(`data-${moduleName}-init`);
+function isInitialised($root, moduleName) {
+ return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
}
/**
@@ -199,7 +199,7 @@ class InitError extends GOVUKFrontendError {
constructor(moduleName, className) {
let errorText = `moduleName not defined in component (\`${className}\`)`;
if (typeof moduleName === 'string') {
- errorText = `Root element (\`$module\`) already initialised (\`${moduleName}\`)`;
+ errorText = `Root element (\`$root\`) already initialised (\`${moduleName}\`)`;
}
super(errorText);
this.name = 'InitError';
@@ -207,19 +207,19 @@ class InitError extends GOVUKFrontendError {
}
class GOVUKFrontendComponent {
- constructor($module) {
+ constructor($root) {
this.checkSupport();
- this.checkInitialised($module);
+ this.checkInitialised($root);
const moduleName = this.constructor.moduleName;
if (typeof moduleName === 'string') {
- moduleName && ($module == null ? void 0 : $module.setAttribute(`data-${moduleName}-init`, ''));
+ moduleName && ($root == null ? void 0 : $root.setAttribute(`data-${moduleName}-init`, ''));
} else {
throw new InitError(moduleName);
}
}
- checkInitialised($module) {
+ checkInitialised($root) {
const moduleName = this.constructor.moduleName;
- if ($module && moduleName && isInitialised($module, moduleName)) {
+ if ($root && moduleName && isInitialised($root, moduleName)) {
throw new InitError(moduleName);
}
}
@@ -259,26 +259,26 @@ class GOVUKFrontendComponent {
*/
class ErrorSummary extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for error summary
+ * @param {Element | null} $root - HTML element to use for error summary
* @param {ErrorSummaryConfig} [config] - Error summary config
*/
- constructor($module, config = {}) {
- super($module);
- this.$module = void 0;
+ constructor($root, config = {}) {
+ super($root);
+ this.$root = void 0;
this.config = void 0;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Error summary',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- this.$module = $module;
- this.config = mergeConfigs(ErrorSummary.defaults, config, normaliseDataset(ErrorSummary, $module.dataset));
+ this.$root = $root;
+ this.config = mergeConfigs(ErrorSummary.defaults, config, normaliseDataset(ErrorSummary, $root.dataset));
if (!this.config.disableAutoFocus) {
- setFocus(this.$module);
+ setFocus(this.$root);
}
- this.$module.addEventListener('click', event => this.handleClick(event));
+ this.$root.addEventListener('click', event => this.handleClick(event));
}
handleClick(event) {
const $target = event.target;
diff --git a/packages/govuk-frontend/dist/govuk/components/error-summary/error-summary.mjs b/packages/govuk-frontend/dist/govuk/components/error-summary/error-summary.mjs
index 7be510b70..7922af9d6 100644
--- a/packages/govuk-frontend/dist/govuk/components/error-summary/error-summary.mjs
+++ b/packages/govuk-frontend/dist/govuk/components/error-summary/error-summary.mjs
@@ -13,26 +13,26 @@ import { GOVUKFrontendComponent } from '../../govuk-frontend-component.mjs';
*/
class ErrorSummary extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for error summary
+ * @param {Element | null} $root - HTML element to use for error summary
* @param {ErrorSummaryConfig} [config] - Error summary config
*/
- constructor($module, config = {}) {
- super($module);
- this.$module = void 0;
+ constructor($root, config = {}) {
+ super($root);
+ this.$root = void 0;
this.config = void 0;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Error summary',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- this.$module = $module;
- this.config = mergeConfigs(ErrorSummary.defaults, config, normaliseDataset(ErrorSummary, $module.dataset));
+ this.$root = $root;
+ this.config = mergeConfigs(ErrorSummary.defaults, config, normaliseDataset(ErrorSummary, $root.dataset));
if (!this.config.disableAutoFocus) {
- setFocus(this.$module);
+ setFocus(this.$root);
}
- this.$module.addEventListener('click', event => this.handleClick(event));
+ this.$root.addEventListener('click', event => this.handleClick(event));
}
handleClick(event) {
const $target = event.target;
diff --git a/packages/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.js b/packages/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.js
index fb4533397..cf4e95da2 100644
--- a/packages/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.js
+++ b/packages/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.js
@@ -74,8 +74,8 @@
}
return newObject[namespace];
}
- function isInitialised($module, moduleName) {
- return $module instanceof HTMLElement && $module.hasAttribute(`data-${moduleName}-init`);
+ function isInitialised($root, moduleName) {
+ return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
}
/**
@@ -175,7 +175,7 @@
constructor(moduleName, className) {
let errorText = `moduleName not defined in component (\`${className}\`)`;
if (typeof moduleName === 'string') {
- errorText = `Root element (\`$module\`) already initialised (\`${moduleName}\`)`;
+ errorText = `Root element (\`$root\`) already initialised (\`${moduleName}\`)`;
}
super(errorText);
this.name = 'InitError';
@@ -183,19 +183,19 @@
}
class GOVUKFrontendComponent {
- constructor($module) {
+ constructor($root) {
this.checkSupport();
- this.checkInitialised($module);
+ this.checkInitialised($root);
const moduleName = this.constructor.moduleName;
if (typeof moduleName === 'string') {
- moduleName && ($module == null ? void 0 : $module.setAttribute(`data-${moduleName}-init`, ''));
+ moduleName && ($root == null ? void 0 : $root.setAttribute(`data-${moduleName}-init`, ''));
} else {
throw new InitError(moduleName);
}
}
- checkInitialised($module) {
+ checkInitialised($root) {
const moduleName = this.constructor.moduleName;
- if ($module && moduleName && isInitialised($module, moduleName)) {
+ if ($root && moduleName && isInitialised($root, moduleName)) {
throw new InitError(moduleName);
}
}
@@ -425,12 +425,12 @@
*/
class ExitThisPage extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element that wraps the Exit This Page button
+ * @param {Element | null} $root - HTML element that wraps the Exit This Page button
* @param {ExitThisPageConfig} [config] - Exit This Page config
*/
- constructor($module, config = {}) {
- super($module);
- this.$module = void 0;
+ constructor($root, config = {}) {
+ super($root);
+ this.$root = void 0;
this.config = void 0;
this.i18n = void 0;
this.$button = void 0;
@@ -443,14 +443,14 @@
this.timeoutTime = 5000;
this.keypressTimeoutId = null;
this.timeoutMessageId = null;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Exit this page',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- const $button = $module.querySelector('.govuk-exit-this-page__button');
+ const $button = $root.querySelector('.govuk-exit-this-page__button');
if (!($button instanceof HTMLAnchorElement)) {
throw new ElementError({
componentName: 'Exit this page',
@@ -459,9 +459,9 @@
identifier: 'Button (`.govuk-exit-this-page__button`)'
});
}
- this.config = mergeConfigs(ExitThisPage.defaults, config, normaliseDataset(ExitThisPage, $module.dataset));
+ this.config = mergeConfigs(ExitThisPage.defaults, config, normaliseDataset(ExitThisPage, $root.dataset));
this.i18n = new I18n(this.config.i18n);
- this.$module = $module;
+ this.$root = $root;
this.$button = $button;
const $skiplinkButton = document.querySelector('.govuk-js-exit-this-page-skiplink');
if ($skiplinkButton instanceof HTMLAnchorElement) {
@@ -480,7 +480,7 @@
this.$updateSpan = document.createElement('span');
this.$updateSpan.setAttribute('role', 'status');
this.$updateSpan.className = 'govuk-visually-hidden';
- this.$module.appendChild(this.$updateSpan);
+ this.$root.appendChild(this.$updateSpan);
}
initButtonClickHandler() {
this.$button.addEventListener('click', this.handleClick.bind(this));
diff --git a/packages/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.mjs b/packages/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.mjs
index 714daefad..7db138801 100644
--- a/packages/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.mjs
+++ b/packages/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.mjs
@@ -68,8 +68,8 @@ function extractConfigByNamespace(Component, dataset, namespace) {
}
return newObject[namespace];
}
-function isInitialised($module, moduleName) {
- return $module instanceof HTMLElement && $module.hasAttribute(`data-${moduleName}-init`);
+function isInitialised($root, moduleName) {
+ return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
}
/**
@@ -169,7 +169,7 @@ class InitError extends GOVUKFrontendError {
constructor(moduleName, className) {
let errorText = `moduleName not defined in component (\`${className}\`)`;
if (typeof moduleName === 'string') {
- errorText = `Root element (\`$module\`) already initialised (\`${moduleName}\`)`;
+ errorText = `Root element (\`$root\`) already initialised (\`${moduleName}\`)`;
}
super(errorText);
this.name = 'InitError';
@@ -177,19 +177,19 @@ class InitError extends GOVUKFrontendError {
}
class GOVUKFrontendComponent {
- constructor($module) {
+ constructor($root) {
this.checkSupport();
- this.checkInitialised($module);
+ this.checkInitialised($root);
const moduleName = this.constructor.moduleName;
if (typeof moduleName === 'string') {
- moduleName && ($module == null ? void 0 : $module.setAttribute(`data-${moduleName}-init`, ''));
+ moduleName && ($root == null ? void 0 : $root.setAttribute(`data-${moduleName}-init`, ''));
} else {
throw new InitError(moduleName);
}
}
- checkInitialised($module) {
+ checkInitialised($root) {
const moduleName = this.constructor.moduleName;
- if ($module && moduleName && isInitialised($module, moduleName)) {
+ if ($root && moduleName && isInitialised($root, moduleName)) {
throw new InitError(moduleName);
}
}
@@ -419,12 +419,12 @@ I18n.pluralRules = {
*/
class ExitThisPage extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element that wraps the Exit This Page button
+ * @param {Element | null} $root - HTML element that wraps the Exit This Page button
* @param {ExitThisPageConfig} [config] - Exit This Page config
*/
- constructor($module, config = {}) {
- super($module);
- this.$module = void 0;
+ constructor($root, config = {}) {
+ super($root);
+ this.$root = void 0;
this.config = void 0;
this.i18n = void 0;
this.$button = void 0;
@@ -437,14 +437,14 @@ class ExitThisPage extends GOVUKFrontendComponent {
this.timeoutTime = 5000;
this.keypressTimeoutId = null;
this.timeoutMessageId = null;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Exit this page',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- const $button = $module.querySelector('.govuk-exit-this-page__button');
+ const $button = $root.querySelector('.govuk-exit-this-page__button');
if (!($button instanceof HTMLAnchorElement)) {
throw new ElementError({
componentName: 'Exit this page',
@@ -453,9 +453,9 @@ class ExitThisPage extends GOVUKFrontendComponent {
identifier: 'Button (`.govuk-exit-this-page__button`)'
});
}
- this.config = mergeConfigs(ExitThisPage.defaults, config, normaliseDataset(ExitThisPage, $module.dataset));
+ this.config = mergeConfigs(ExitThisPage.defaults, config, normaliseDataset(ExitThisPage, $root.dataset));
this.i18n = new I18n(this.config.i18n);
- this.$module = $module;
+ this.$root = $root;
this.$button = $button;
const $skiplinkButton = document.querySelector('.govuk-js-exit-this-page-skiplink');
if ($skiplinkButton instanceof HTMLAnchorElement) {
@@ -474,7 +474,7 @@ class ExitThisPage extends GOVUKFrontendComponent {
this.$updateSpan = document.createElement('span');
this.$updateSpan.setAttribute('role', 'status');
this.$updateSpan.className = 'govuk-visually-hidden';
- this.$module.appendChild(this.$updateSpan);
+ this.$root.appendChild(this.$updateSpan);
}
initButtonClickHandler() {
this.$button.addEventListener('click', this.handleClick.bind(this));
diff --git a/packages/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.mjs b/packages/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.mjs
index 7ad1c9360..d3d70a618 100644
--- a/packages/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.mjs
+++ b/packages/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.mjs
@@ -11,12 +11,12 @@ import { I18n } from '../../i18n.mjs';
*/
class ExitThisPage extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element that wraps the Exit This Page button
+ * @param {Element | null} $root - HTML element that wraps the Exit This Page button
* @param {ExitThisPageConfig} [config] - Exit This Page config
*/
- constructor($module, config = {}) {
- super($module);
- this.$module = void 0;
+ constructor($root, config = {}) {
+ super($root);
+ this.$root = void 0;
this.config = void 0;
this.i18n = void 0;
this.$button = void 0;
@@ -29,14 +29,14 @@ class ExitThisPage extends GOVUKFrontendComponent {
this.timeoutTime = 5000;
this.keypressTimeoutId = null;
this.timeoutMessageId = null;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Exit this page',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- const $button = $module.querySelector('.govuk-exit-this-page__button');
+ const $button = $root.querySelector('.govuk-exit-this-page__button');
if (!($button instanceof HTMLAnchorElement)) {
throw new ElementError({
componentName: 'Exit this page',
@@ -45,9 +45,9 @@ class ExitThisPage extends GOVUKFrontendComponent {
identifier: 'Button (`.govuk-exit-this-page__button`)'
});
}
- this.config = mergeConfigs(ExitThisPage.defaults, config, normaliseDataset(ExitThisPage, $module.dataset));
+ this.config = mergeConfigs(ExitThisPage.defaults, config, normaliseDataset(ExitThisPage, $root.dataset));
this.i18n = new I18n(this.config.i18n);
- this.$module = $module;
+ this.$root = $root;
this.$button = $button;
const $skiplinkButton = document.querySelector('.govuk-js-exit-this-page-skiplink');
if ($skiplinkButton instanceof HTMLAnchorElement) {
@@ -66,7 +66,7 @@ class ExitThisPage extends GOVUKFrontendComponent {
this.$updateSpan = document.createElement('span');
this.$updateSpan.setAttribute('role', 'status');
this.$updateSpan.className = 'govuk-visually-hidden';
- this.$module.appendChild(this.$updateSpan);
+ this.$root.appendChild(this.$updateSpan);
}
initButtonClickHandler() {
this.$button.addEventListener('click', this.handleClick.bind(this));
diff --git a/packages/govuk-frontend/dist/govuk/components/header/header.bundle.js b/packages/govuk-frontend/dist/govuk/components/header/header.bundle.js
index 5bbcbe1be..7a14eb734 100644
--- a/packages/govuk-frontend/dist/govuk/components/header/header.bundle.js
+++ b/packages/govuk-frontend/dist/govuk/components/header/header.bundle.js
@@ -12,8 +12,8 @@
value: value || undefined
};
}
- function isInitialised($module, moduleName) {
- return $module instanceof HTMLElement && $module.hasAttribute(`data-${moduleName}-init`);
+ function isInitialised($root, moduleName) {
+ return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
}
/**
@@ -94,7 +94,7 @@
constructor(moduleName, className) {
let errorText = `moduleName not defined in component (\`${className}\`)`;
if (typeof moduleName === 'string') {
- errorText = `Root element (\`$module\`) already initialised (\`${moduleName}\`)`;
+ errorText = `Root element (\`$root\`) already initialised (\`${moduleName}\`)`;
}
super(errorText);
this.name = 'InitError';
@@ -102,19 +102,19 @@
}
class GOVUKFrontendComponent {
- constructor($module) {
+ constructor($root) {
this.checkSupport();
- this.checkInitialised($module);
+ this.checkInitialised($root);
const moduleName = this.constructor.moduleName;
if (typeof moduleName === 'string') {
- moduleName && ($module == null ? void 0 : $module.setAttribute(`data-${moduleName}-init`, ''));
+ moduleName && ($root == null ? void 0 : $root.setAttribute(`data-${moduleName}-init`, ''));
} else {
throw new InitError(moduleName);
}
}
- checkInitialised($module) {
+ checkInitialised($root) {
const moduleName = this.constructor.moduleName;
- if ($module && moduleName && isInitialised($module, moduleName)) {
+ if ($root && moduleName && isInitialised($root, moduleName)) {
throw new InitError(moduleName);
}
}
@@ -154,24 +154,24 @@
* Apply a matchMedia for desktop which will trigger a state sync if the
* browser viewport moves between states.
*
- * @param {Element | null} $module - HTML element to use for header
+ * @param {Element | null} $root - HTML element to use for header
*/
- constructor($module) {
- super($module);
- this.$module = void 0;
+ constructor($root) {
+ super($root);
+ this.$root = void 0;
this.$menuButton = void 0;
this.$menu = void 0;
this.menuIsOpen = false;
this.mql = null;
- if (!$module) {
+ if (!$root) {
throw new ElementError({
componentName: 'Header',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- this.$module = $module;
- const $menuButton = $module.querySelector('.govuk-js-header-toggle');
+ this.$root = $root;
+ const $menuButton = $root.querySelector('.govuk-js-header-toggle');
if (!$menuButton) {
return this;
}
diff --git a/packages/govuk-frontend/dist/govuk/components/header/header.bundle.mjs b/packages/govuk-frontend/dist/govuk/components/header/header.bundle.mjs
index 224c11925..dcf6bd7ee 100644
--- a/packages/govuk-frontend/dist/govuk/components/header/header.bundle.mjs
+++ b/packages/govuk-frontend/dist/govuk/components/header/header.bundle.mjs
@@ -6,8 +6,8 @@ function getBreakpoint(name) {
value: value || undefined
};
}
-function isInitialised($module, moduleName) {
- return $module instanceof HTMLElement && $module.hasAttribute(`data-${moduleName}-init`);
+function isInitialised($root, moduleName) {
+ return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
}
/**
@@ -88,7 +88,7 @@ class InitError extends GOVUKFrontendError {
constructor(moduleName, className) {
let errorText = `moduleName not defined in component (\`${className}\`)`;
if (typeof moduleName === 'string') {
- errorText = `Root element (\`$module\`) already initialised (\`${moduleName}\`)`;
+ errorText = `Root element (\`$root\`) already initialised (\`${moduleName}\`)`;
}
super(errorText);
this.name = 'InitError';
@@ -96,19 +96,19 @@ class InitError extends GOVUKFrontendError {
}
class GOVUKFrontendComponent {
- constructor($module) {
+ constructor($root) {
this.checkSupport();
- this.checkInitialised($module);
+ this.checkInitialised($root);
const moduleName = this.constructor.moduleName;
if (typeof moduleName === 'string') {
- moduleName && ($module == null ? void 0 : $module.setAttribute(`data-${moduleName}-init`, ''));
+ moduleName && ($root == null ? void 0 : $root.setAttribute(`data-${moduleName}-init`, ''));
} else {
throw new InitError(moduleName);
}
}
- checkInitialised($module) {
+ checkInitialised($root) {
const moduleName = this.constructor.moduleName;
- if ($module && moduleName && isInitialised($module, moduleName)) {
+ if ($root && moduleName && isInitialised($root, moduleName)) {
throw new InitError(moduleName);
}
}
@@ -148,24 +148,24 @@ class Header extends GOVUKFrontendComponent {
* Apply a matchMedia for desktop which will trigger a state sync if the
* browser viewport moves between states.
*
- * @param {Element | null} $module - HTML element to use for header
+ * @param {Element | null} $root - HTML element to use for header
*/
- constructor($module) {
- super($module);
- this.$module = void 0;
+ constructor($root) {
+ super($root);
+ this.$root = void 0;
this.$menuButton = void 0;
this.$menu = void 0;
this.menuIsOpen = false;
this.mql = null;
- if (!$module) {
+ if (!$root) {
throw new ElementError({
componentName: 'Header',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- this.$module = $module;
- const $menuButton = $module.querySelector('.govuk-js-header-toggle');
+ this.$root = $root;
+ const $menuButton = $root.querySelector('.govuk-js-header-toggle');
if (!$menuButton) {
return this;
}
diff --git a/packages/govuk-frontend/dist/govuk/components/header/header.mjs b/packages/govuk-frontend/dist/govuk/components/header/header.mjs
index a464c6b1f..0014e0efb 100644
--- a/packages/govuk-frontend/dist/govuk/components/header/header.mjs
+++ b/packages/govuk-frontend/dist/govuk/components/header/header.mjs
@@ -12,24 +12,24 @@ class Header extends GOVUKFrontendComponent {
* Apply a matchMedia for desktop which will trigger a state sync if the
* browser viewport moves between states.
*
- * @param {Element | null} $module - HTML element to use for header
+ * @param {Element | null} $root - HTML element to use for header
*/
- constructor($module) {
- super($module);
- this.$module = void 0;
+ constructor($root) {
+ super($root);
+ this.$root = void 0;
this.$menuButton = void 0;
this.$menu = void 0;
this.menuIsOpen = false;
this.mql = null;
- if (!$module) {
+ if (!$root) {
throw new ElementError({
componentName: 'Header',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- this.$module = $module;
- const $menuButton = $module.querySelector('.govuk-js-header-toggle');
+ this.$root = $root;
+ const $menuButton = $root.querySelector('.govuk-js-header-toggle');
if (!$menuButton) {
return this;
}
diff --git a/packages/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.js b/packages/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.js
index 6a44dd11c..89e2c697b 100644
--- a/packages/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.js
+++ b/packages/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.js
@@ -98,8 +98,8 @@
(_options$onBeforeFocu = options.onBeforeFocus) == null || _options$onBeforeFocu.call($element);
$element.focus();
}
- function isInitialised($module, moduleName) {
- return $module instanceof HTMLElement && $module.hasAttribute(`data-${moduleName}-init`);
+ function isInitialised($root, moduleName) {
+ return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
}
/**
@@ -199,7 +199,7 @@
constructor(moduleName, className) {
let errorText = `moduleName not defined in component (\`${className}\`)`;
if (typeof moduleName === 'string') {
- errorText = `Root element (\`$module\`) already initialised (\`${moduleName}\`)`;
+ errorText = `Root element (\`$root\`) already initialised (\`${moduleName}\`)`;
}
super(errorText);
this.name = 'InitError';
@@ -207,19 +207,19 @@
}
class GOVUKFrontendComponent {
- constructor($module) {
+ constructor($root) {
this.checkSupport();
- this.checkInitialised($module);
+ this.checkInitialised($root);
const moduleName = this.constructor.moduleName;
if (typeof moduleName === 'string') {
- moduleName && ($module == null ? void 0 : $module.setAttribute(`data-${moduleName}-init`, ''));
+ moduleName && ($root == null ? void 0 : $root.setAttribute(`data-${moduleName}-init`, ''));
} else {
throw new InitError(moduleName);
}
}
- checkInitialised($module) {
+ checkInitialised($root) {
const moduleName = this.constructor.moduleName;
- if ($module && moduleName && isInitialised($module, moduleName)) {
+ if ($root && moduleName && isInitialised($root, moduleName)) {
throw new InitError(moduleName);
}
}
@@ -256,24 +256,24 @@
*/
class NotificationBanner extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for notification banner
+ * @param {Element | null} $root - HTML element to use for notification banner
* @param {NotificationBannerConfig} [config] - Notification banner config
*/
- constructor($module, config = {}) {
- super($module);
- this.$module = void 0;
+ constructor($root, config = {}) {
+ super($root);
+ this.$root = void 0;
this.config = void 0;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Notification banner',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- this.$module = $module;
- this.config = mergeConfigs(NotificationBanner.defaults, config, normaliseDataset(NotificationBanner, $module.dataset));
- if (this.$module.getAttribute('role') === 'alert' && !this.config.disableAutoFocus) {
- setFocus(this.$module);
+ this.$root = $root;
+ this.config = mergeConfigs(NotificationBanner.defaults, config, normaliseDataset(NotificationBanner, $root.dataset));
+ if (this.$root.getAttribute('role') === 'alert' && !this.config.disableAutoFocus) {
+ setFocus(this.$root);
}
}
}
diff --git a/packages/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.mjs b/packages/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.mjs
index 7b0c12d39..6f3792072 100644
--- a/packages/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.mjs
+++ b/packages/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.mjs
@@ -92,8 +92,8 @@ function setFocus($element, options = {}) {
(_options$onBeforeFocu = options.onBeforeFocus) == null || _options$onBeforeFocu.call($element);
$element.focus();
}
-function isInitialised($module, moduleName) {
- return $module instanceof HTMLElement && $module.hasAttribute(`data-${moduleName}-init`);
+function isInitialised($root, moduleName) {
+ return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
}
/**
@@ -193,7 +193,7 @@ class InitError extends GOVUKFrontendError {
constructor(moduleName, className) {
let errorText = `moduleName not defined in component (\`${className}\`)`;
if (typeof moduleName === 'string') {
- errorText = `Root element (\`$module\`) already initialised (\`${moduleName}\`)`;
+ errorText = `Root element (\`$root\`) already initialised (\`${moduleName}\`)`;
}
super(errorText);
this.name = 'InitError';
@@ -201,19 +201,19 @@ class InitError extends GOVUKFrontendError {
}
class GOVUKFrontendComponent {
- constructor($module) {
+ constructor($root) {
this.checkSupport();
- this.checkInitialised($module);
+ this.checkInitialised($root);
const moduleName = this.constructor.moduleName;
if (typeof moduleName === 'string') {
- moduleName && ($module == null ? void 0 : $module.setAttribute(`data-${moduleName}-init`, ''));
+ moduleName && ($root == null ? void 0 : $root.setAttribute(`data-${moduleName}-init`, ''));
} else {
throw new InitError(moduleName);
}
}
- checkInitialised($module) {
+ checkInitialised($root) {
const moduleName = this.constructor.moduleName;
- if ($module && moduleName && isInitialised($module, moduleName)) {
+ if ($root && moduleName && isInitialised($root, moduleName)) {
throw new InitError(moduleName);
}
}
@@ -250,24 +250,24 @@ class GOVUKFrontendComponent {
*/
class NotificationBanner extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for notification banner
+ * @param {Element | null} $root - HTML element to use for notification banner
* @param {NotificationBannerConfig} [config] - Notification banner config
*/
- constructor($module, config = {}) {
- super($module);
- this.$module = void 0;
+ constructor($root, config = {}) {
+ super($root);
+ this.$root = void 0;
this.config = void 0;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Notification banner',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- this.$module = $module;
- this.config = mergeConfigs(NotificationBanner.defaults, config, normaliseDataset(NotificationBanner, $module.dataset));
- if (this.$module.getAttribute('role') === 'alert' && !this.config.disableAutoFocus) {
- setFocus(this.$module);
+ this.$root = $root;
+ this.config = mergeConfigs(NotificationBanner.defaults, config, normaliseDataset(NotificationBanner, $root.dataset));
+ if (this.$root.getAttribute('role') === 'alert' && !this.config.disableAutoFocus) {
+ setFocus(this.$root);
}
}
}
diff --git a/packages/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.mjs b/packages/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.mjs
index 77e2b61d6..323c9f23b 100644
--- a/packages/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.mjs
+++ b/packages/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.mjs
@@ -10,24 +10,24 @@ import { GOVUKFrontendComponent } from '../../govuk-frontend-component.mjs';
*/
class NotificationBanner extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for notification banner
+ * @param {Element | null} $root - HTML element to use for notification banner
* @param {NotificationBannerConfig} [config] - Notification banner config
*/
- constructor($module, config = {}) {
- super($module);
- this.$module = void 0;
+ constructor($root, config = {}) {
+ super($root);
+ this.$root = void 0;
this.config = void 0;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Notification banner',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- this.$module = $module;
- this.config = mergeConfigs(NotificationBanner.defaults, config, normaliseDataset(NotificationBanner, $module.dataset));
- if (this.$module.getAttribute('role') === 'alert' && !this.config.disableAutoFocus) {
- setFocus(this.$module);
+ this.$root = $root;
+ this.config = mergeConfigs(NotificationBanner.defaults, config, normaliseDataset(NotificationBanner, $root.dataset));
+ if (this.$root.getAttribute('role') === 'alert' && !this.config.disableAutoFocus) {
+ setFocus(this.$root);
}
}
}
diff --git a/packages/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.js b/packages/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.js
index 38adb9a52..3d126b524 100644
--- a/packages/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.js
+++ b/packages/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.js
@@ -79,8 +79,8 @@
}
return newObject[namespace];
}
- function isInitialised($module, moduleName) {
- return $module instanceof HTMLElement && $module.hasAttribute(`data-${moduleName}-init`);
+ function isInitialised($root, moduleName) {
+ return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
}
/**
@@ -180,7 +180,7 @@
constructor(moduleName, className) {
let errorText = `moduleName not defined in component (\`${className}\`)`;
if (typeof moduleName === 'string') {
- errorText = `Root element (\`$module\`) already initialised (\`${moduleName}\`)`;
+ errorText = `Root element (\`$root\`) already initialised (\`${moduleName}\`)`;
}
super(errorText);
this.name = 'InitError';
@@ -188,19 +188,19 @@
}
class GOVUKFrontendComponent {
- constructor($module) {
+ constructor($root) {
this.checkSupport();
- this.checkInitialised($module);
+ this.checkInitialised($root);
const moduleName = this.constructor.moduleName;
if (typeof moduleName === 'string') {
- moduleName && ($module == null ? void 0 : $module.setAttribute(`data-${moduleName}-init`, ''));
+ moduleName && ($root == null ? void 0 : $root.setAttribute(`data-${moduleName}-init`, ''));
} else {
throw new InitError(moduleName);
}
}
- checkInitialised($module) {
+ checkInitialised($root) {
const moduleName = this.constructor.moduleName;
- if ($module && moduleName && isInitialised($module, moduleName)) {
+ if ($root && moduleName && isInitialised($root, moduleName)) {
throw new InitError(moduleName);
}
}
@@ -430,25 +430,25 @@
*/
class PasswordInput extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for password input
+ * @param {Element | null} $root - HTML element to use for password input
* @param {PasswordInputConfig} [config] - Password input config
*/
- constructor($module, config = {}) {
+ constructor($root, config = {}) {
super();
- this.$module = void 0;
+ this.$root = void 0;
this.config = void 0;
this.i18n = void 0;
this.$input = void 0;
this.$showHideButton = void 0;
this.$screenReaderStatusMessage = void 0;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Password input',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- const $input = $module.querySelector('.govuk-js-password-input-input');
+ const $input = $root.querySelector('.govuk-js-password-input-input');
if (!($input instanceof HTMLInputElement)) {
throw new ElementError({
componentName: 'Password input',
@@ -460,7 +460,7 @@
if ($input.type !== 'password') {
throw new ElementError('Password input: Form field (`.govuk-js-password-input-input`) must be of type `password`.');
}
- const $showHideButton = $module.querySelector('.govuk-js-password-input-toggle');
+ const $showHideButton = $root.querySelector('.govuk-js-password-input-toggle');
if (!($showHideButton instanceof HTMLButtonElement)) {
throw new ElementError({
componentName: 'Password input',
@@ -472,12 +472,12 @@
if ($showHideButton.type !== 'button') {
throw new ElementError('Password input: Button (`.govuk-js-password-input-toggle`) must be of type `button`.');
}
- this.$module = $module;
+ this.$root = $root;
this.$input = $input;
this.$showHideButton = $showHideButton;
- this.config = mergeConfigs(PasswordInput.defaults, config, normaliseDataset(PasswordInput, $module.dataset));
+ this.config = mergeConfigs(PasswordInput.defaults, config, normaliseDataset(PasswordInput, $root.dataset));
this.i18n = new I18n(this.config.i18n, {
- locale: closestAttributeValue($module, 'lang')
+ locale: closestAttributeValue($root, 'lang')
});
this.$showHideButton.removeAttribute('hidden');
const $screenReaderStatusMessage = document.createElement('div');
diff --git a/packages/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.mjs b/packages/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.mjs
index a0465d235..3d6a3388f 100644
--- a/packages/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.mjs
+++ b/packages/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.mjs
@@ -73,8 +73,8 @@ function extractConfigByNamespace(Component, dataset, namespace) {
}
return newObject[namespace];
}
-function isInitialised($module, moduleName) {
- return $module instanceof HTMLElement && $module.hasAttribute(`data-${moduleName}-init`);
+function isInitialised($root, moduleName) {
+ return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
}
/**
@@ -174,7 +174,7 @@ class InitError extends GOVUKFrontendError {
constructor(moduleName, className) {
let errorText = `moduleName not defined in component (\`${className}\`)`;
if (typeof moduleName === 'string') {
- errorText = `Root element (\`$module\`) already initialised (\`${moduleName}\`)`;
+ errorText = `Root element (\`$root\`) already initialised (\`${moduleName}\`)`;
}
super(errorText);
this.name = 'InitError';
@@ -182,19 +182,19 @@ class InitError extends GOVUKFrontendError {
}
class GOVUKFrontendComponent {
- constructor($module) {
+ constructor($root) {
this.checkSupport();
- this.checkInitialised($module);
+ this.checkInitialised($root);
const moduleName = this.constructor.moduleName;
if (typeof moduleName === 'string') {
- moduleName && ($module == null ? void 0 : $module.setAttribute(`data-${moduleName}-init`, ''));
+ moduleName && ($root == null ? void 0 : $root.setAttribute(`data-${moduleName}-init`, ''));
} else {
throw new InitError(moduleName);
}
}
- checkInitialised($module) {
+ checkInitialised($root) {
const moduleName = this.constructor.moduleName;
- if ($module && moduleName && isInitialised($module, moduleName)) {
+ if ($root && moduleName && isInitialised($root, moduleName)) {
throw new InitError(moduleName);
}
}
@@ -424,25 +424,25 @@ I18n.pluralRules = {
*/
class PasswordInput extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for password input
+ * @param {Element | null} $root - HTML element to use for password input
* @param {PasswordInputConfig} [config] - Password input config
*/
- constructor($module, config = {}) {
+ constructor($root, config = {}) {
super();
- this.$module = void 0;
+ this.$root = void 0;
this.config = void 0;
this.i18n = void 0;
this.$input = void 0;
this.$showHideButton = void 0;
this.$screenReaderStatusMessage = void 0;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Password input',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- const $input = $module.querySelector('.govuk-js-password-input-input');
+ const $input = $root.querySelector('.govuk-js-password-input-input');
if (!($input instanceof HTMLInputElement)) {
throw new ElementError({
componentName: 'Password input',
@@ -454,7 +454,7 @@ class PasswordInput extends GOVUKFrontendComponent {
if ($input.type !== 'password') {
throw new ElementError('Password input: Form field (`.govuk-js-password-input-input`) must be of type `password`.');
}
- const $showHideButton = $module.querySelector('.govuk-js-password-input-toggle');
+ const $showHideButton = $root.querySelector('.govuk-js-password-input-toggle');
if (!($showHideButton instanceof HTMLButtonElement)) {
throw new ElementError({
componentName: 'Password input',
@@ -466,12 +466,12 @@ class PasswordInput extends GOVUKFrontendComponent {
if ($showHideButton.type !== 'button') {
throw new ElementError('Password input: Button (`.govuk-js-password-input-toggle`) must be of type `button`.');
}
- this.$module = $module;
+ this.$root = $root;
this.$input = $input;
this.$showHideButton = $showHideButton;
- this.config = mergeConfigs(PasswordInput.defaults, config, normaliseDataset(PasswordInput, $module.dataset));
+ this.config = mergeConfigs(PasswordInput.defaults, config, normaliseDataset(PasswordInput, $root.dataset));
this.i18n = new I18n(this.config.i18n, {
- locale: closestAttributeValue($module, 'lang')
+ locale: closestAttributeValue($root, 'lang')
});
this.$showHideButton.removeAttribute('hidden');
const $screenReaderStatusMessage = document.createElement('div');
diff --git a/packages/govuk-frontend/dist/govuk/components/password-input/password-input.mjs b/packages/govuk-frontend/dist/govuk/components/password-input/password-input.mjs
index 1a0eec466..941f12b09 100644
--- a/packages/govuk-frontend/dist/govuk/components/password-input/password-input.mjs
+++ b/packages/govuk-frontend/dist/govuk/components/password-input/password-input.mjs
@@ -12,25 +12,25 @@ import { I18n } from '../../i18n.mjs';
*/
class PasswordInput extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for password input
+ * @param {Element | null} $root - HTML element to use for password input
* @param {PasswordInputConfig} [config] - Password input config
*/
- constructor($module, config = {}) {
+ constructor($root, config = {}) {
super();
- this.$module = void 0;
+ this.$root = void 0;
this.config = void 0;
this.i18n = void 0;
this.$input = void 0;
this.$showHideButton = void 0;
this.$screenReaderStatusMessage = void 0;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Password input',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- const $input = $module.querySelector('.govuk-js-password-input-input');
+ const $input = $root.querySelector('.govuk-js-password-input-input');
if (!($input instanceof HTMLInputElement)) {
throw new ElementError({
componentName: 'Password input',
@@ -42,7 +42,7 @@ class PasswordInput extends GOVUKFrontendComponent {
if ($input.type !== 'password') {
throw new ElementError('Password input: Form field (`.govuk-js-password-input-input`) must be of type `password`.');
}
- const $showHideButton = $module.querySelector('.govuk-js-password-input-toggle');
+ const $showHideButton = $root.querySelector('.govuk-js-password-input-toggle');
if (!($showHideButton instanceof HTMLButtonElement)) {
throw new ElementError({
componentName: 'Password input',
@@ -54,12 +54,12 @@ class PasswordInput extends GOVUKFrontendComponent {
if ($showHideButton.type !== 'button') {
throw new ElementError('Password input: Button (`.govuk-js-password-input-toggle`) must be of type `button`.');
}
- this.$module = $module;
+ this.$root = $root;
this.$input = $input;
this.$showHideButton = $showHideButton;
- this.config = mergeConfigs(PasswordInput.defaults, config, normaliseDataset(PasswordInput, $module.dataset));
+ this.config = mergeConfigs(PasswordInput.defaults, config, normaliseDataset(PasswordInput, $root.dataset));
this.i18n = new I18n(this.config.i18n, {
- locale: closestAttributeValue($module, 'lang')
+ locale: closestAttributeValue($root, 'lang')
});
this.$showHideButton.removeAttribute('hidden');
const $screenReaderStatusMessage = document.createElement('div');
diff --git a/packages/govuk-frontend/dist/govuk/components/radios/radios.bundle.js b/packages/govuk-frontend/dist/govuk/components/radios/radios.bundle.js
index 7444eea07..f95954099 100644
--- a/packages/govuk-frontend/dist/govuk/components/radios/radios.bundle.js
+++ b/packages/govuk-frontend/dist/govuk/components/radios/radios.bundle.js
@@ -43,15 +43,15 @@
constructor(moduleName, className) {
let errorText = `moduleName not defined in component (\`${className}\`)`;
if (typeof moduleName === 'string') {
- errorText = `Root element (\`$module\`) already initialised (\`${moduleName}\`)`;
+ errorText = `Root element (\`$root\`) already initialised (\`${moduleName}\`)`;
}
super(errorText);
this.name = 'InitError';
}
}
- function isInitialised($module, moduleName) {
- return $module instanceof HTMLElement && $module.hasAttribute(`data-${moduleName}-init`);
+ function isInitialised($root, moduleName) {
+ return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
}
/**
@@ -94,19 +94,19 @@
*/
class GOVUKFrontendComponent {
- constructor($module) {
+ constructor($root) {
this.checkSupport();
- this.checkInitialised($module);
+ this.checkInitialised($root);
const moduleName = this.constructor.moduleName;
if (typeof moduleName === 'string') {
- moduleName && ($module == null ? void 0 : $module.setAttribute(`data-${moduleName}-init`, ''));
+ moduleName && ($root == null ? void 0 : $root.setAttribute(`data-${moduleName}-init`, ''));
} else {
throw new InitError(moduleName);
}
}
- checkInitialised($module) {
+ checkInitialised($root) {
const moduleName = this.constructor.moduleName;
- if ($module && moduleName && isInitialised($module, moduleName)) {
+ if ($root && moduleName && isInitialised($root, moduleName)) {
throw new InitError(moduleName);
}
}
@@ -154,27 +154,27 @@
* (for example if the user has navigated back), and set up event handlers to
* keep the reveal in sync with the radio state.
*
- * @param {Element | null} $module - HTML element to use for radios
+ * @param {Element | null} $root - HTML element to use for radios
*/
- constructor($module) {
- super($module);
- this.$module = void 0;
+ constructor($root) {
+ super($root);
+ this.$root = void 0;
this.$inputs = void 0;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Radios',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- const $inputs = $module.querySelectorAll('input[type="radio"]');
+ const $inputs = $root.querySelectorAll('input[type="radio"]');
if (!$inputs.length) {
throw new ElementError({
componentName: 'Radios',
identifier: 'Form inputs (`<input type="radio">`)'
});
}
- this.$module = $module;
+ this.$root = $root;
this.$inputs = $inputs;
this.$inputs.forEach($input => {
const targetId = $input.getAttribute('data-aria-controls');
@@ -192,7 +192,7 @@
});
window.addEventListener('pageshow', () => this.syncAllConditionalReveals());
this.syncAllConditionalReveals();
- this.$module.addEventListener('click', event => this.handleClick(event));
+ this.$root.addEventListener('click', event => this.handleClick(event));
}
syncAllConditionalReveals() {
this.$inputs.forEach($input => this.syncConditionalRevealWithInputState($input));
diff --git a/packages/govuk-frontend/dist/govuk/components/radios/radios.bundle.mjs b/packages/govuk-frontend/dist/govuk/components/radios/radios.bundle.mjs
index 1fd810d35..fcdfa2b42 100644
--- a/packages/govuk-frontend/dist/govuk/components/radios/radios.bundle.mjs
+++ b/packages/govuk-frontend/dist/govuk/components/radios/radios.bundle.mjs
@@ -37,15 +37,15 @@ class InitError extends GOVUKFrontendError {
constructor(moduleName, className) {
let errorText = `moduleName not defined in component (\`${className}\`)`;
if (typeof moduleName === 'string') {
- errorText = `Root element (\`$module\`) already initialised (\`${moduleName}\`)`;
+ errorText = `Root element (\`$root\`) already initialised (\`${moduleName}\`)`;
}
super(errorText);
this.name = 'InitError';
}
}
-function isInitialised($module, moduleName) {
- return $module instanceof HTMLElement && $module.hasAttribute(`data-${moduleName}-init`);
+function isInitialised($root, moduleName) {
+ return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
}
/**
@@ -88,19 +88,19 @@ function isSupported($scope = document.body) {
*/
class GOVUKFrontendComponent {
- constructor($module) {
+ constructor($root) {
this.checkSupport();
- this.checkInitialised($module);
+ this.checkInitialised($root);
const moduleName = this.constructor.moduleName;
if (typeof moduleName === 'string') {
- moduleName && ($module == null ? void 0 : $module.setAttribute(`data-${moduleName}-init`, ''));
+ moduleName && ($root == null ? void 0 : $root.setAttribute(`data-${moduleName}-init`, ''));
} else {
throw new InitError(moduleName);
}
}
- checkInitialised($module) {
+ checkInitialised($root) {
const moduleName = this.constructor.moduleName;
- if ($module && moduleName && isInitialised($module, moduleName)) {
+ if ($root && moduleName && isInitialised($root, moduleName)) {
throw new InitError(moduleName);
}
}
@@ -148,27 +148,27 @@ class Radios extends GOVUKFrontendComponent {
* (for example if the user has navigated back), and set up event handlers to
* keep the reveal in sync with the radio state.
*
- * @param {Element | null} $module - HTML element to use for radios
+ * @param {Element | null} $root - HTML element to use for radios
*/
- constructor($module) {
- super($module);
- this.$module = void 0;
+ constructor($root) {
+ super($root);
+ this.$root = void 0;
this.$inputs = void 0;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Radios',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- const $inputs = $module.querySelectorAll('input[type="radio"]');
+ const $inputs = $root.querySelectorAll('input[type="radio"]');
if (!$inputs.length) {
throw new ElementError({
componentName: 'Radios',
identifier: 'Form inputs (`<input type="radio">`)'
});
}
- this.$module = $module;
+ this.$root = $root;
this.$inputs = $inputs;
this.$inputs.forEach($input => {
const targetId = $input.getAttribute('data-aria-controls');
@@ -186,7 +186,7 @@ class Radios extends GOVUKFrontendComponent {
});
window.addEventListener('pageshow', () => this.syncAllConditionalReveals());
this.syncAllConditionalReveals();
- this.$module.addEventListener('click', event => this.handleClick(event));
+ this.$root.addEventListener('click', event => this.handleClick(event));
}
syncAllConditionalReveals() {
this.$inputs.forEach($input => this.syncConditionalRevealWithInputState($input));
diff --git a/packages/govuk-frontend/dist/govuk/components/radios/radios.mjs b/packages/govuk-frontend/dist/govuk/components/radios/radios.mjs
index f74cefb64..6885b8371 100644
--- a/packages/govuk-frontend/dist/govuk/components/radios/radios.mjs
+++ b/packages/govuk-frontend/dist/govuk/components/radios/radios.mjs
@@ -19,27 +19,27 @@ class Radios extends GOVUKFrontendComponent {
* (for example if the user has navigated back), and set up event handlers to
* keep the reveal in sync with the radio state.
*
- * @param {Element | null} $module - HTML element to use for radios
+ * @param {Element | null} $root - HTML element to use for radios
*/
- constructor($module) {
- super($module);
- this.$module = void 0;
+ constructor($root) {
+ super($root);
+ this.$root = void 0;
this.$inputs = void 0;
- if (!($module instanceof HTMLElement)) {
+ if (!($root instanceof HTMLElement)) {
throw new ElementError({
componentName: 'Radios',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- const $inputs = $module.querySelectorAll('input[type="radio"]');
+ const $inputs = $root.querySelectorAll('input[type="radio"]');
if (!$inputs.length) {
throw new ElementError({
componentName: 'Radios',
identifier: 'Form inputs (`<input type="radio">`)'
});
}
- this.$module = $module;
+ this.$root = $root;
this.$inputs = $inputs;
this.$inputs.forEach($input => {
const targetId = $input.getAttribute('data-aria-controls');
@@ -57,7 +57,7 @@ class Radios extends GOVUKFrontendComponent {
});
window.addEventListener('pageshow', () => this.syncAllConditionalReveals());
this.syncAllConditionalReveals();
- this.$module.addEventListener('click', event => this.handleClick(event));
+ this.$root.addEventListener('click', event => this.handleClick(event));
}
syncAllConditionalReveals() {
this.$inputs.forEach($input => this.syncConditionalRevealWithInputState($input));
diff --git a/packages/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.js b/packages/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.js
index 09499031c..20077d8ab 100644
--- a/packages/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.js
+++ b/packages/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.js
@@ -12,8 +12,8 @@
value: value || undefined
};
}
- function isInitialised($module, moduleName) {
- return $module instanceof HTMLElement && $module.hasAttribute(`data-${moduleName}-init`);
+ function isInitialised($root, moduleName) {
+ return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
}
/**
@@ -94,7 +94,7 @@
constructor(moduleName, className) {
let errorText = `moduleName not defined in component (\`${className}\`)`;
if (typeof moduleName === 'string') {
- errorText = `Root element (\`$module\`) already initialised (\`${moduleName}\`)`;
+ errorText = `Root element (\`$root\`) already initialised (\`${moduleName}\`)`;
}
super(errorText);
this.name = 'InitError';
@@ -102,19 +102,19 @@
}
class GOVUKFrontendComponent {
- constructor($module) {
+ constructor($root) {
this.checkSupport();
- this.checkInitialised($module);
+ this.checkInitialised($root);
const moduleName = this.constructor.moduleName;
if (typeof moduleName === 'string') {
- moduleName && ($module == null ? void 0 : $module.setAttribute(`data-${moduleName}-init`, ''));
+ moduleName && ($root == null ? void 0 : $root.setAttribute(`data-${moduleName}-init`, ''));
} else {
throw new InitError(moduleName);
}
}
- checkInitialised($module) {
+ checkInitialised($root) {
const moduleName = this.constructor.moduleName;
- if ($module && moduleName && isInitialised($module, moduleName)) {
+ if ($root && moduleName && isInitialised($root, moduleName)) {
throw new InitError(moduleName);
}
}
@@ -151,24 +151,24 @@
*/
class ServiceNavigation extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for header
+ * @param {Element | null} $root - HTML element to use for header
*/
- constructor($module) {
+ constructor($root) {
super();
- this.$module = void 0;
+ this.$root = void 0;
this.$menuButton = void 0;
this.$menu = void 0;
this.menuIsOpen = false;
this.mql = null;
- if (!$module) {
+ if (!$root) {
throw new ElementError({
componentName: 'Service Navigation',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- this.$module = $module;
- const $menuButton = $module.querySelector('.govuk-js-service-navigation-toggle');
+ this.$root = $root;
+ const $menuButton = $root.querySelector('.govuk-js-service-navigation-toggle');
if (!$menuButton) {
return this;
}
diff --git a/packages/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.mjs b/packages/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.mjs
index c944b0639..f5e16a044 100644
--- a/packages/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.mjs
+++ b/packages/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.mjs
@@ -6,8 +6,8 @@ function getBreakpoint(name) {
value: value || undefined
};
}
-function isInitialised($module, moduleName) {
- return $module instanceof HTMLElement && $module.hasAttribute(`data-${moduleName}-init`);
+function isInitialised($root, moduleName) {
+ return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
}
/**
@@ -88,7 +88,7 @@ class InitError extends GOVUKFrontendError {
constructor(moduleName, className) {
let errorText = `moduleName not defined in component (\`${className}\`)`;
if (typeof moduleName === 'string') {
- errorText = `Root element (\`$module\`) already initialised (\`${moduleName}\`)`;
+ errorText = `Root element (\`$root\`) already initialised (\`${moduleName}\`)`;
}
super(errorText);
this.name = 'InitError';
@@ -96,19 +96,19 @@ class InitError extends GOVUKFrontendError {
}
class GOVUKFrontendComponent {
- constructor($module) {
+ constructor($root) {
this.checkSupport();
- this.checkInitialised($module);
+ this.checkInitialised($root);
const moduleName = this.constructor.moduleName;
if (typeof moduleName === 'string') {
- moduleName && ($module == null ? void 0 : $module.setAttribute(`data-${moduleName}-init`, ''));
+ moduleName && ($root == null ? void 0 : $root.setAttribute(`data-${moduleName}-init`, ''));
} else {
throw new InitError(moduleName);
}
}
- checkInitialised($module) {
+ checkInitialised($root) {
const moduleName = this.constructor.moduleName;
- if ($module && moduleName && isInitialised($module, moduleName)) {
+ if ($root && moduleName && isInitialised($root, moduleName)) {
throw new InitError(moduleName);
}
}
@@ -145,24 +145,24 @@ class GOVUKFrontendComponent {
*/
class ServiceNavigation extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for header
+ * @param {Element | null} $root - HTML element to use for header
*/
- constructor($module) {
+ constructor($root) {
super();
- this.$module = void 0;
+ this.$root = void 0;
this.$menuButton = void 0;
this.$menu = void 0;
this.menuIsOpen = false;
this.mql = null;
- if (!$module) {
+ if (!$root) {
throw new ElementError({
componentName: 'Service Navigation',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- this.$module = $module;
- const $menuButton = $module.querySelector('.govuk-js-service-navigation-toggle');
+ this.$root = $root;
+ const $menuButton = $root.querySelector('.govuk-js-service-navigation-toggle');
if (!$menuButton) {
return this;
}
diff --git a/packages/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.mjs b/packages/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.mjs
index e3006114b..98e3f56e6 100644
--- a/packages/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.mjs
+++ b/packages/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.mjs
@@ -9,24 +9,24 @@ import { GOVUKFrontendComponent } from '../../govuk-frontend-component.mjs';
*/
class ServiceNavigation extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for header
+ * @param {Element | null} $root - HTML element to use for header
*/
- constructor($module) {
+ constructor($root) {
super();
- this.$module = void 0;
+ this.$root = void 0;
this.$menuButton = void 0;
this.$menu = void 0;
this.menuIsOpen = false;
this.mql = null;
- if (!$module) {
+ if (!$root) {
throw new ElementError({
componentName: 'Service Navigation',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- this.$module = $module;
- const $menuButton = $module.querySelector('.govuk-js-service-navigation-toggle');
+ this.$root = $root;
+ const $menuButton = $root.querySelector('.govuk-js-service-navigation-toggle');
if (!$menuButton) {
return this;
}
diff --git a/packages/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.js b/packages/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.js
index 29e6e9727..de62dbacb 100644
--- a/packages/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.js
+++ b/packages/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.js
@@ -34,8 +34,8 @@
(_options$onBeforeFocu = options.onBeforeFocus) == null || _options$onBeforeFocu.call($element);
$element.focus();
}
- function isInitialised($module, moduleName) {
- return $module instanceof HTMLElement && $module.hasAttribute(`data-${moduleName}-init`);
+ function isInitialised($root, moduleName) {
+ return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
}
/**
@@ -116,7 +116,7 @@
constructor(moduleName, className) {
let errorText = `moduleName not defined in component (\`${className}\`)`;
if (typeof moduleName === 'string') {
- errorText = `Root element (\`$module\`) already initialised (\`${moduleName}\`)`;
+ errorText = `Root element (\`$root\`) already initialised (\`${moduleName}\`)`;
}
super(errorText);
this.name = 'InitError';
@@ -124,19 +124,19 @@
}
class GOVUKFrontendComponent {
- constructor($module) {
+ constructor($root) {
this.checkSupport();
- this.checkInitialised($module);
+ this.checkInitialised($root);
const moduleName = this.constructor.moduleName;
if (typeof moduleName === 'string') {
- moduleName && ($module == null ? void 0 : $module.setAttribute(`data-${moduleName}-init`, ''));
+ moduleName && ($root == null ? void 0 : $root.setAttribute(`data-${moduleName}-init`, ''));
} else {
throw new InitError(moduleName);
}
}
- checkInitialised($module) {
+ checkInitialised($root) {
const moduleName = this.constructor.moduleName;
- if ($module && moduleName && isInitialised($module, moduleName)) {
+ if ($root && moduleName && isInitialised($root, moduleName)) {
throw new InitError(moduleName);
}
}
@@ -173,29 +173,29 @@
*/
class SkipLink extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for skip link
- * @throws {ElementError} when $module is not set or the wrong type
- * @throws {ElementError} when $module.hash does not contain a hash
+ * @param {Element | null} $root - HTML element to use for skip link
+ * @throws {ElementError} when $root is not set or the wrong type
+ * @throws {ElementError} when $root.hash does not contain a hash
* @throws {ElementError} when the linked element is missing or the wrong type
*/
- constructor($module) {
- var _this$$module$getAttr;
- super($module);
- this.$module = void 0;
- if (!($module instanceof HTMLAnchorElement)) {
+ constructor($root) {
+ var _this$$root$getAttrib;
+ super($root);
+ this.$root = void 0;
+ if (!($root instanceof HTMLAnchorElement)) {
throw new ElementError({
componentName: 'Skip link',
- element: $module,
+ element: $root,
expectedType: 'HTMLAnchorElement',
- identifier: 'Root element (`$module`)'
+ identifier: 'Root element (`$root`)'
});
}
- this.$module = $module;
- const hash = this.$module.hash;
- const href = (_this$$module$getAttr = this.$module.getAttribute('href')) != null ? _this$$module$getAttr : '';
+ this.$root = $root;
+ const hash = this.$root.hash;
+ const href = (_this$$root$getAttrib = this.$root.getAttribute('href')) != null ? _this$$root$getAttrib : '';
let url;
try {
- url = new window.URL(this.$module.href);
+ url = new window.URL(this.$root.href);
} catch (error) {
throw new ElementError(`Skip link: Target link (\`href="${href}"\`) is invalid`);
}
@@ -214,7 +214,7 @@
identifier: `Target content (\`id="${linkedElementId}"\`)`
});
}
- this.$module.addEventListener('click', () => setFocus($linkedElement, {
+ this.$root.addEventListener('click', () => setFocus($linkedElement, {
onBeforeFocus() {
$linkedElement.classList.add('govuk-skip-link-focused-element');
},
diff --git a/packages/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.mjs b/packages/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.mjs
index b5b902021..d99d1740b 100644
--- a/packages/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.mjs
+++ b/packages/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.mjs
@@ -28,8 +28,8 @@ function setFocus($element, options = {}) {
(_options$onBeforeFocu = options.onBeforeFocus) == null || _options$onBeforeFocu.call($element);
$element.focus();
}
-function isInitialised($module, moduleName) {
- return $module instanceof HTMLElement && $module.hasAttribute(`data-${moduleName}-init`);
+function isInitialised($root, moduleName) {
+ return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
}
/**
@@ -110,7 +110,7 @@ class InitError extends GOVUKFrontendError {
constructor(moduleName, className) {
let errorText = `moduleName not defined in component (\`${className}\`)`;
if (typeof moduleName === 'string') {
- errorText = `Root element (\`$module\`) already initialised (\`${moduleName}\`)`;
+ errorText = `Root element (\`$root\`) already initialised (\`${moduleName}\`)`;
}
super(errorText);
this.name = 'InitError';
@@ -118,19 +118,19 @@ class InitError extends GOVUKFrontendError {
}
class GOVUKFrontendComponent {
- constructor($module) {
+ constructor($root) {
this.checkSupport();
- this.checkInitialised($module);
+ this.checkInitialised($root);
const moduleName = this.constructor.moduleName;
if (typeof moduleName === 'string') {
- moduleName && ($module == null ? void 0 : $module.setAttribute(`data-${moduleName}-init`, ''));
+ moduleName && ($root == null ? void 0 : $root.setAttribute(`data-${moduleName}-init`, ''));
} else {
throw new InitError(moduleName);
}
}
- checkInitialised($module) {
+ checkInitialised($root) {
const moduleName = this.constructor.moduleName;
- if ($module && moduleName && isInitialised($module, moduleName)) {
+ if ($root && moduleName && isInitialised($root, moduleName)) {
throw new InitError(moduleName);
}
}
@@ -167,29 +167,29 @@ class GOVUKFrontendComponent {
*/
class SkipLink extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for skip link
- * @throws {ElementError} when $module is not set or the wrong type
- * @throws {ElementError} when $module.hash does not contain a hash
+ * @param {Element | null} $root - HTML element to use for skip link
+ * @throws {ElementError} when $root is not set or the wrong type
+ * @throws {ElementError} when $root.hash does not contain a hash
* @throws {ElementError} when the linked element is missing or the wrong type
*/
- constructor($module) {
- var _this$$module$getAttr;
- super($module);
- this.$module = void 0;
- if (!($module instanceof HTMLAnchorElement)) {
+ constructor($root) {
+ var _this$$root$getAttrib;
+ super($root);
+ this.$root = void 0;
+ if (!($root instanceof HTMLAnchorElement)) {
throw new ElementError({
componentName: 'Skip link',
- element: $module,
+ element: $root,
expectedType: 'HTMLAnchorElement',
- identifier: 'Root element (`$module`)'
+ identifier: 'Root element (`$root`)'
});
}
- this.$module = $module;
- const hash = this.$module.hash;
- const href = (_this$$module$getAttr = this.$module.getAttribute('href')) != null ? _this$$module$getAttr : '';
+ this.$root = $root;
+ const hash = this.$root.hash;
+ const href = (_this$$root$getAttrib = this.$root.getAttribute('href')) != null ? _this$$root$getAttrib : '';
let url;
try {
- url = new window.URL(this.$module.href);
+ url = new window.URL(this.$root.href);
} catch (error) {
throw new ElementError(`Skip link: Target link (\`href="${href}"\`) is invalid`);
}
@@ -208,7 +208,7 @@ class SkipLink extends GOVUKFrontendComponent {
identifier: `Target content (\`id="${linkedElementId}"\`)`
});
}
- this.$module.addEventListener('click', () => setFocus($linkedElement, {
+ this.$root.addEventListener('click', () => setFocus($linkedElement, {
onBeforeFocus() {
$linkedElement.classList.add('govuk-skip-link-focused-element');
},
diff --git a/packages/govuk-frontend/dist/govuk/components/skip-link/skip-link.mjs b/packages/govuk-frontend/dist/govuk/components/skip-link/skip-link.mjs
index 90e6fc436..89a0bfd10 100644
--- a/packages/govuk-frontend/dist/govuk/components/skip-link/skip-link.mjs
+++ b/packages/govuk-frontend/dist/govuk/components/skip-link/skip-link.mjs
@@ -9,29 +9,29 @@ import { GOVUKFrontendComponent } from '../../govuk-frontend-component.mjs';
*/
class SkipLink extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for skip link
- * @throws {ElementError} when $module is not set or the wrong type
- * @throws {ElementError} when $module.hash does not contain a hash
+ * @param {Element | null} $root - HTML element to use for skip link
+ * @throws {ElementError} when $root is not set or the wrong type
+ * @throws {ElementError} when $root.hash does not contain a hash
* @throws {ElementError} when the linked element is missing or the wrong type
*/
- constructor($module) {
- var _this$$module$getAttr;
- super($module);
- this.$module = void 0;
- if (!($module instanceof HTMLAnchorElement)) {
+ constructor($root) {
+ var _this$$root$getAttrib;
+ super($root);
+ this.$root = void 0;
+ if (!($root instanceof HTMLAnchorElement)) {
throw new ElementError({
componentName: 'Skip link',
- element: $module,
+ element: $root,
expectedType: 'HTMLAnchorElement',
- identifier: 'Root element (`$module`)'
+ identifier: 'Root element (`$root`)'
});
}
- this.$module = $module;
- const hash = this.$module.hash;
- const href = (_this$$module$getAttr = this.$module.getAttribute('href')) != null ? _this$$module$getAttr : '';
+ this.$root = $root;
+ const hash = this.$root.hash;
+ const href = (_this$$root$getAttrib = this.$root.getAttribute('href')) != null ? _this$$root$getAttrib : '';
let url;
try {
- url = new window.URL(this.$module.href);
+ url = new window.URL(this.$root.href);
} catch (error) {
throw new ElementError(`Skip link: Target link (\`href="${href}"\`) is invalid`);
}
@@ -50,7 +50,7 @@ class SkipLink extends GOVUKFrontendComponent {
identifier: `Target content (\`id="${linkedElementId}"\`)`
});
}
- this.$module.addEventListener('click', () => setFocus($linkedElement, {
+ this.$root.addEventListener('click', () => setFocus($linkedElement, {
onBeforeFocus() {
$linkedElement.classList.add('govuk-skip-link-focused-element');
},
diff --git a/packages/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.js b/packages/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.js
index 3400748c8..bbbda8189 100644
--- a/packages/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.js
+++ b/packages/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.js
@@ -18,8 +18,8 @@
value: value || undefined
};
}
- function isInitialised($module, moduleName) {
- return $module instanceof HTMLElement && $module.hasAttribute(`data-${moduleName}-init`);
+ function isInitialised($root, moduleName) {
+ return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
}
/**
@@ -100,7 +100,7 @@
constructor(moduleName, className) {
let errorText = `moduleName not defined in component (\`${className}\`)`;
if (typeof moduleName === 'string') {
- errorText = `Root element (\`$module\`) already initialised (\`${moduleName}\`)`;
+ errorText = `Root element (\`$root\`) already initialised (\`${moduleName}\`)`;
}
super(errorText);
this.name = 'InitError';
@@ -108,19 +108,19 @@
}
class GOVUKFrontendComponent {
- constructor($module) {
+ constructor($root) {
this.checkSupport();
- this.checkInitialised($module);
+ this.checkInitialised($root);
const moduleName = this.constructor.moduleName;
if (typeof moduleName === 'string') {
- moduleName && ($module == null ? void 0 : $module.setAttribute(`data-${moduleName}-init`, ''));
+ moduleName && ($root == null ? void 0 : $root.setAttribute(`data-${moduleName}-init`, ''));
} else {
throw new InitError(moduleName);
}
}
- checkInitialised($module) {
+ checkInitialised($root) {
const moduleName = this.constructor.moduleName;
- if ($module && moduleName && isInitialised($module, moduleName)) {
+ if ($root && moduleName && isInitialised($root, moduleName)) {
throw new InitError(moduleName);
}
}
@@ -157,11 +157,11 @@
*/
class Tabs extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for tabs
+ * @param {Element | null} $root - HTML element to use for tabs
*/
- constructor($module) {
- super($module);
- this.$module = void 0;
+ constructor($root) {
+ super($root);
+ this.$root = void 0;
this.$tabs = void 0;
this.$tabList = void 0;
this.$tabListItems = void 0;
@@ -171,27 +171,27 @@
this.boundTabKeydown = void 0;
this.boundOnHashChange = void 0;
this.mql = null;
- if (!$module) {
+ if (!$root) {
throw new ElementError({
componentName: 'Tabs',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- const $tabs = $module.querySelectorAll('a.govuk-tabs__tab');
+ const $tabs = $root.querySelectorAll('a.govuk-tabs__tab');
if (!$tabs.length) {
throw new ElementError({
componentName: 'Tabs',
identifier: 'Links (`<a class="govuk-tabs__tab">`)'
});
}
- this.$module = $module;
+ this.$root = $root;
this.$tabs = $tabs;
this.boundTabClick = this.onTabClick.bind(this);
this.boundTabKeydown = this.onTabKeydown.bind(this);
this.boundOnHashChange = this.onHashChange.bind(this);
- const $tabList = this.$module.querySelector('.govuk-tabs__list');
- const $tabListItems = this.$module.querySelectorAll('li.govuk-tabs__list-item');
+ const $tabList = this.$root.querySelector('.govuk-tabs__list');
+ const $tabListItems = this.$root.querySelectorAll('li.govuk-tabs__list-item');
if (!$tabList) {
throw new ElementError({
componentName: 'Tabs',
@@ -287,7 +287,7 @@
this.showPanel($tab);
}
getTab(hash) {
- return this.$module.querySelector(`a.govuk-tabs__tab[href="${hash}"]`);
+ return this.$root.querySelector(`a.govuk-tabs__tab[href="${hash}"]`);
}
setAttributes($tab) {
const panelId = getFragmentFromUrl($tab.href);
@@ -398,7 +398,7 @@
if (!panelId) {
return null;
}
- return this.$module.querySelector(`#${panelId}`);
+ return this.$root.querySelector(`#${panelId}`);
}
showPanel($tab) {
const $panel = this.getPanel($tab);
@@ -431,7 +431,7 @@
$tab.setAttribute('tabindex', '0');
}
getCurrentTab() {
- return this.$module.querySelector('.govuk-tabs__list-item--selected a.govuk-tabs__tab');
+ return this.$root.querySelector('.govuk-tabs__list-item--selected a.govuk-tabs__tab');
}
}
Tabs.moduleName = 'govuk-tabs';
diff --git a/packages/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.mjs b/packages/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.mjs
index fb5ce2526..f2b136dbf 100644
--- a/packages/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.mjs
+++ b/packages/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.mjs
@@ -12,8 +12,8 @@ function getBreakpoint(name) {
value: value || undefined
};
}
-function isInitialised($module, moduleName) {
- return $module instanceof HTMLElement && $module.hasAttribute(`data-${moduleName}-init`);
+function isInitialised($root, moduleName) {
+ return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
}
/**
@@ -94,7 +94,7 @@ class InitError extends GOVUKFrontendError {
constructor(moduleName, className) {
let errorText = `moduleName not defined in component (\`${className}\`)`;
if (typeof moduleName === 'string') {
- errorText = `Root element (\`$module\`) already initialised (\`${moduleName}\`)`;
+ errorText = `Root element (\`$root\`) already initialised (\`${moduleName}\`)`;
}
super(errorText);
this.name = 'InitError';
@@ -102,19 +102,19 @@ class InitError extends GOVUKFrontendError {
}
class GOVUKFrontendComponent {
- constructor($module) {
+ constructor($root) {
this.checkSupport();
- this.checkInitialised($module);
+ this.checkInitialised($root);
const moduleName = this.constructor.moduleName;
if (typeof moduleName === 'string') {
- moduleName && ($module == null ? void 0 : $module.setAttribute(`data-${moduleName}-init`, ''));
+ moduleName && ($root == null ? void 0 : $root.setAttribute(`data-${moduleName}-init`, ''));
} else {
throw new InitError(moduleName);
}
}
- checkInitialised($module) {
+ checkInitialised($root) {
const moduleName = this.constructor.moduleName;
- if ($module && moduleName && isInitialised($module, moduleName)) {
+ if ($root && moduleName && isInitialised($root, moduleName)) {
throw new InitError(moduleName);
}
}
@@ -151,11 +151,11 @@ class GOVUKFrontendComponent {
*/
class Tabs extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for tabs
+ * @param {Element | null} $root - HTML element to use for tabs
*/
- constructor($module) {
- super($module);
- this.$module = void 0;
+ constructor($root) {
+ super($root);
+ this.$root = void 0;
this.$tabs = void 0;
this.$tabList = void 0;
this.$tabListItems = void 0;
@@ -165,27 +165,27 @@ class Tabs extends GOVUKFrontendComponent {
this.boundTabKeydown = void 0;
this.boundOnHashChange = void 0;
this.mql = null;
- if (!$module) {
+ if (!$root) {
throw new ElementError({
componentName: 'Tabs',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- const $tabs = $module.querySelectorAll('a.govuk-tabs__tab');
+ const $tabs = $root.querySelectorAll('a.govuk-tabs__tab');
if (!$tabs.length) {
throw new ElementError({
componentName: 'Tabs',
identifier: 'Links (`<a class="govuk-tabs__tab">`)'
});
}
- this.$module = $module;
+ this.$root = $root;
this.$tabs = $tabs;
this.boundTabClick = this.onTabClick.bind(this);
this.boundTabKeydown = this.onTabKeydown.bind(this);
this.boundOnHashChange = this.onHashChange.bind(this);
- const $tabList = this.$module.querySelector('.govuk-tabs__list');
- const $tabListItems = this.$module.querySelectorAll('li.govuk-tabs__list-item');
+ const $tabList = this.$root.querySelector('.govuk-tabs__list');
+ const $tabListItems = this.$root.querySelectorAll('li.govuk-tabs__list-item');
if (!$tabList) {
throw new ElementError({
componentName: 'Tabs',
@@ -281,7 +281,7 @@ class Tabs extends GOVUKFrontendComponent {
this.showPanel($tab);
}
getTab(hash) {
- return this.$module.querySelector(`a.govuk-tabs__tab[href="${hash}"]`);
+ return this.$root.querySelector(`a.govuk-tabs__tab[href="${hash}"]`);
}
setAttributes($tab) {
const panelId = getFragmentFromUrl($tab.href);
@@ -392,7 +392,7 @@ class Tabs extends GOVUKFrontendComponent {
if (!panelId) {
return null;
}
- return this.$module.querySelector(`#${panelId}`);
+ return this.$root.querySelector(`#${panelId}`);
}
showPanel($tab) {
const $panel = this.getPanel($tab);
@@ -425,7 +425,7 @@ class Tabs extends GOVUKFrontendComponent {
$tab.setAttribute('tabindex', '0');
}
getCurrentTab() {
- return this.$module.querySelector('.govuk-tabs__list-item--selected a.govuk-tabs__tab');
+ return this.$root.querySelector('.govuk-tabs__list-item--selected a.govuk-tabs__tab');
}
}
Tabs.moduleName = 'govuk-tabs';
diff --git a/packages/govuk-frontend/dist/govuk/components/tabs/tabs.mjs b/packages/govuk-frontend/dist/govuk/components/tabs/tabs.mjs
index 50a2cad7a..1381f509b 100644
--- a/packages/govuk-frontend/dist/govuk/components/tabs/tabs.mjs
+++ b/packages/govuk-frontend/dist/govuk/components/tabs/tabs.mjs
@@ -9,11 +9,11 @@ import { GOVUKFrontendComponent } from '../../govuk-frontend-component.mjs';
*/
class Tabs extends GOVUKFrontendComponent {
/**
- * @param {Element | null} $module - HTML element to use for tabs
+ * @param {Element | null} $root - HTML element to use for tabs
*/
- constructor($module) {
- super($module);
- this.$module = void 0;
+ constructor($root) {
+ super($root);
+ this.$root = void 0;
this.$tabs = void 0;
this.$tabList = void 0;
this.$tabListItems = void 0;
@@ -23,27 +23,27 @@ class Tabs extends GOVUKFrontendComponent {
this.boundTabKeydown = void 0;
this.boundOnHashChange = void 0;
this.mql = null;
- if (!$module) {
+ if (!$root) {
throw new ElementError({
componentName: 'Tabs',
- element: $module,
- identifier: 'Root element (`$module`)'
+ element: $root,
+ identifier: 'Root element (`$root`)'
});
}
- const $tabs = $module.querySelectorAll('a.govuk-tabs__tab');
+ const $tabs = $root.querySelectorAll('a.govuk-tabs__tab');
if (!$tabs.length) {
throw new ElementError({
componentName: 'Tabs',
identifier: 'Links (`<a class="govuk-tabs__tab">`)'
});
}
- this.$module = $module;
+ this.$root = $root;
this.$tabs = $tabs;
this.boundTabClick = this.onTabClick.bind(this);
this.boundTabKeydown = this.onTabKeydown.bind(this);
this.boundOnHashChange = this.onHashChange.bind(this);
- const $tabList = this.$module.querySelector('.govuk-tabs__list');
- const $tabListItems = this.$module.querySelectorAll('li.govuk-tabs__list-item');
+ const $tabList = this.$root.querySelector('.govuk-tabs__list');
+ const $tabListItems = this.$root.querySelectorAll('li.govuk-tabs__list-item');
if (!$tabList) {
throw new ElementError({
componentName: 'Tabs',
@@ -139,7 +139,7 @@ class Tabs extends GOVUKFrontendComponent {
this.showPanel($tab);
}
getTab(hash) {
- return this.$module.querySelector(`a.govuk-tabs__tab[href="${hash}"]`);
+ return this.$root.querySelector(`a.govuk-tabs__tab[href="${hash}"]`);
}
setAttributes($tab) {
const panelId = getFragmentFromUrl($tab.href);
@@ -250,7 +250,7 @@ class Tabs extends GOVUKFrontendComponent {
if (!panelId) {
return null;
}
- return this.$module.querySelector(`#${panelId}`);
+ return this.$root.querySelector(`#${panelId}`);
}
showPanel($tab) {
const $panel = this.getPanel($tab);
@@ -283,7 +283,7 @@ class Tabs extends GOVUKFrontendComponent {
$tab.setAttribute('tabindex', '0');
}
getCurrentTab() {
- return this.$module.querySelector('.govuk-tabs__list-item--selected a.govuk-tabs__tab');
+ return this.$root.querySelector('.govuk-tabs__list-item--selected a.govuk-tabs__tab');
}
}
Tabs.moduleName = 'govuk-tabs';
diff --git a/packages/govuk-frontend/dist/govuk/errors/index.mjs b/packages/govuk-frontend/dist/govuk/errors/index.mjs
index 5fdb0858c..1b3fe218e 100644
--- a/packages/govuk-frontend/dist/govuk/errors/index.mjs
+++ b/packages/govuk-frontend/dist/govuk/errors/index.mjs
@@ -43,7 +43,7 @@ class InitError extends GOVUKFrontendError {
constructor(moduleName, className) {
let errorText = `moduleName not defined in component (\`${className}\`)`;
if (typeof moduleName === 'string') {
- errorText = `Root element (\`$module\`) already initialised (\`${moduleName}\`)`;
+ errorText = `Root element (\`$root\`) already initialised (\`${moduleName}\`)`;
}
super(errorText);
this.name = 'InitError';
diff --git a/packages/govuk-frontend/dist/govuk/govuk-frontend-component.mjs b/packages/govuk-frontend/dist/govuk/govuk-frontend-component.mjs
index 2bf203f9d..be9a98534 100644
--- a/packages/govuk-frontend/dist/govuk/govuk-frontend-component.mjs
+++ b/packages/govuk-frontend/dist/govuk/govuk-frontend-component.mjs
@@ -2,19 +2,19 @@ import { isInitialised, isSupported } from './common/index.mjs';
import { InitError, SupportError } from './errors/index.mjs';
class GOVUKFrontendComponent {
- constructor($module) {
+ constructor($root) {
this.checkSupport();
- this.checkInitialised($module);
+ this.checkInitialised($root);
const moduleName = this.constructor.moduleName;
if (typeof moduleName === 'string') {
- moduleName && ($module == null ? void 0 : $module.setAttribute(`data-${moduleName}-init`, ''));
+ moduleName && ($root == null ? void 0 : $root.setAttribute(`data-${moduleName}-init`, ''));
} else {
throw new InitError(moduleName);
}
}
- checkInitialised($module) {
+ checkInitialised($root) {
const moduleName = this.constructor.moduleName;
- if ($module && moduleName && isInitialised($module, moduleName)) {
+ if ($root && moduleName && isInitialised($root, moduleName)) {
throw new InitError(moduleName);
}
}
Action run for 73f79a7 |
I can't find any mentions of |
patrickpatrickpatrick
approved these changes
Sep 20, 2024
1 task
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Internal refactoring to rename
$module
to$root
across the codebase: components, tests, helpers and documentation.This change is not breaking and won't even affect the component behaviours as:
$module
was the name of positional arguments which are in the same positionthis.$module
was@private
, so not to be used by external codeThe PR splits the renaming component by component for easier review.
Closes #5322