govuk_publishing_components 35.3.3 → 35.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (266) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/component_guide/application.scss +37 -1
  3. data/app/assets/stylesheets/govuk_publishing_components/components/_metadata.scss +10 -6
  4. data/app/assets/stylesheets/govuk_publishing_components/components/_organisation-logo.scss +2 -2
  5. data/app/views/govuk_publishing_components/component_guide/example.html.erb +1 -1
  6. data/app/views/govuk_publishing_components/component_guide/preview.html.erb +1 -1
  7. data/app/views/govuk_publishing_components/component_guide/show.html.erb +1 -1
  8. data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +2 -2
  9. data/app/views/govuk_publishing_components/components/_metadata.html.erb +1 -1
  10. data/app/views/govuk_publishing_components/components/_share_links.html.erb +6 -2
  11. data/app/views/govuk_publishing_components/components/_step_by_step_nav_related.html.erb +1 -1
  12. data/app/views/govuk_publishing_components/components/docs/metadata.yml +1 -3
  13. data/app/views/govuk_publishing_components/components/docs/organisation_logo.yml +5 -5
  14. data/app/views/govuk_publishing_components/components/docs/step_by_step_nav_related.yml +1 -0
  15. data/app/views/layouts/govuk_publishing_components/application.html.erb +1 -0
  16. data/lib/govuk_publishing_components/app_helpers/asset_helper.rb +4 -0
  17. data/lib/govuk_publishing_components/presenters/breadcrumbs_helper.rb +1 -1
  18. data/lib/govuk_publishing_components/version.rb +1 -1
  19. data/node_modules/axe-core/axe.d.ts +77 -6
  20. data/node_modules/axe-core/axe.js +955 -600
  21. data/node_modules/axe-core/axe.min.js +2 -2
  22. data/node_modules/axe-core/locales/_template.json +6 -6
  23. data/node_modules/axe-core/locales/ja.json +91 -11
  24. data/node_modules/axe-core/package.json +5 -5
  25. data/node_modules/axe-core/sri-history.json +4 -0
  26. data/node_modules/govuk-frontend/README.md +4 -5
  27. data/node_modules/govuk-frontend/govuk/all-ie8.scss +8 -0
  28. data/node_modules/govuk-frontend/govuk/all.js +738 -258
  29. data/node_modules/govuk-frontend/govuk/all.js.map +1 -1
  30. data/node_modules/govuk-frontend/govuk/common/closest-attribute-value.js +11 -7
  31. data/node_modules/govuk-frontend/govuk/common/closest-attribute-value.js.map +1 -1
  32. data/node_modules/govuk-frontend/govuk/common/govuk-frontend-version.js +17 -0
  33. data/node_modules/govuk-frontend/govuk/common/govuk-frontend-version.js.map +1 -0
  34. data/node_modules/govuk-frontend/govuk/common/index.js +16 -4
  35. data/node_modules/govuk-frontend/govuk/common/index.js.map +1 -1
  36. data/node_modules/govuk-frontend/govuk/common/normalise-dataset.js +20 -10
  37. data/node_modules/govuk-frontend/govuk/common/normalise-dataset.js.map +1 -1
  38. data/node_modules/govuk-frontend/govuk/common.js +16 -4
  39. data/node_modules/govuk-frontend/govuk/common.js.map +1 -1
  40. data/node_modules/govuk-frontend/govuk/components/accordion/_index.scss +3 -3
  41. data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js +234 -86
  42. data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js.map +1 -1
  43. data/node_modules/govuk-frontend/govuk/components/accordion/fixtures.json +32 -13
  44. data/node_modules/govuk-frontend/govuk/components/accordion/macro-options.json +8 -2
  45. data/node_modules/govuk-frontend/govuk/components/accordion/template.njk +1 -0
  46. data/node_modules/govuk-frontend/govuk/components/back-link/_index.scss +1 -1
  47. data/node_modules/govuk-frontend/govuk/components/back-link/fixtures.json +1 -1
  48. data/node_modules/govuk-frontend/govuk/components/back-link/macro-options.json +1 -1
  49. data/node_modules/govuk-frontend/govuk/components/breadcrumbs/_index.scss +1 -1
  50. data/node_modules/govuk-frontend/govuk/components/breadcrumbs/fixtures.json +12 -12
  51. data/node_modules/govuk-frontend/govuk/components/breadcrumbs/macro-options.json +1 -1
  52. data/node_modules/govuk-frontend/govuk/components/button/_index.scss +8 -6
  53. data/node_modules/govuk-frontend/govuk/components/button/button.js +54 -19
  54. data/node_modules/govuk-frontend/govuk/components/button/button.js.map +1 -1
  55. data/node_modules/govuk-frontend/govuk/components/button/fixtures.json +11 -1
  56. data/node_modules/govuk-frontend/govuk/components/button/macro-options.json +7 -1
  57. data/node_modules/govuk-frontend/govuk/components/button/template.njk +1 -1
  58. data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +170 -76
  59. data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js.map +1 -1
  60. data/node_modules/govuk-frontend/govuk/components/character-count/fixtures.json +24 -24
  61. data/node_modules/govuk-frontend/govuk/components/character-count/macro-options.json +3 -3
  62. data/node_modules/govuk-frontend/govuk/components/checkboxes/_index.scss +6 -6
  63. data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js +75 -24
  64. data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js.map +1 -1
  65. data/node_modules/govuk-frontend/govuk/components/checkboxes/fixtures.json +47 -47
  66. data/node_modules/govuk-frontend/govuk/components/checkboxes/macro-options.json +1 -1
  67. data/node_modules/govuk-frontend/govuk/components/checkboxes/template.njk +3 -3
  68. data/node_modules/govuk-frontend/govuk/components/cookie-banner/fixtures.json +24 -24
  69. data/node_modules/govuk-frontend/govuk/components/cookie-banner/macro-options.json +1 -1
  70. data/node_modules/govuk-frontend/govuk/components/date-input/fixtures.json +26 -26
  71. data/node_modules/govuk-frontend/govuk/components/date-input/macro-options.json +1 -1
  72. data/node_modules/govuk-frontend/govuk/components/date-input/template.njk +1 -1
  73. data/node_modules/govuk-frontend/govuk/components/details/details.js +39 -13
  74. data/node_modules/govuk-frontend/govuk/components/details/details.js.map +1 -1
  75. data/node_modules/govuk-frontend/govuk/components/details/fixtures.json +1 -1
  76. data/node_modules/govuk-frontend/govuk/components/details/macro-options.json +1 -1
  77. data/node_modules/govuk-frontend/govuk/components/error-message/fixtures.json +10 -10
  78. data/node_modules/govuk-frontend/govuk/components/error-message/macro-options.json +1 -1
  79. data/node_modules/govuk-frontend/govuk/components/error-summary/error-summary.js +67 -27
  80. data/node_modules/govuk-frontend/govuk/components/error-summary/error-summary.js.map +1 -1
  81. data/node_modules/govuk-frontend/govuk/components/error-summary/fixtures.json +19 -19
  82. data/node_modules/govuk-frontend/govuk/components/error-summary/macro-options.json +1 -1
  83. data/node_modules/govuk-frontend/govuk/components/fieldset/fixtures.json +19 -19
  84. data/node_modules/govuk-frontend/govuk/components/fieldset/macro-options.json +1 -1
  85. data/node_modules/govuk-frontend/govuk/components/file-upload/_index.scss +6 -1
  86. data/node_modules/govuk-frontend/govuk/components/file-upload/fixtures.json +14 -14
  87. data/node_modules/govuk-frontend/govuk/components/file-upload/macro-options.json +7 -1
  88. data/node_modules/govuk-frontend/govuk/components/file-upload/template.njk +2 -1
  89. data/node_modules/govuk-frontend/govuk/components/footer/_index.scss +0 -7
  90. data/node_modules/govuk-frontend/govuk/components/footer/fixtures.json +24 -24
  91. data/node_modules/govuk-frontend/govuk/components/footer/macro-options.json +1 -1
  92. data/node_modules/govuk-frontend/govuk/components/header/fixtures.json +22 -22
  93. data/node_modules/govuk-frontend/govuk/components/header/header.js +46 -14
  94. data/node_modules/govuk-frontend/govuk/components/header/header.js.map +1 -1
  95. data/node_modules/govuk-frontend/govuk/components/header/macro-options.json +1 -1
  96. data/node_modules/govuk-frontend/govuk/components/header/template.njk +1 -1
  97. data/node_modules/govuk-frontend/govuk/components/hint/fixtures.json +1 -1
  98. data/node_modules/govuk-frontend/govuk/components/hint/macro-options.json +1 -1
  99. data/node_modules/govuk-frontend/govuk/components/input/_index.scss +15 -3
  100. data/node_modules/govuk-frontend/govuk/components/input/fixtures.json +54 -41
  101. data/node_modules/govuk-frontend/govuk/components/input/macro-options.json +7 -1
  102. data/node_modules/govuk-frontend/govuk/components/input/template.njk +2 -1
  103. data/node_modules/govuk-frontend/govuk/components/inset-text/fixtures.json +1 -1
  104. data/node_modules/govuk-frontend/govuk/components/inset-text/macro-options.json +1 -1
  105. data/node_modules/govuk-frontend/govuk/components/label/fixtures.json +6 -6
  106. data/node_modules/govuk-frontend/govuk/components/label/macro-options.json +1 -1
  107. data/node_modules/govuk-frontend/govuk/components/notification-banner/fixtures.json +1 -1
  108. data/node_modules/govuk-frontend/govuk/components/notification-banner/macro-options.json +1 -1
  109. data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js +49 -22
  110. data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js.map +1 -1
  111. data/node_modules/govuk-frontend/govuk/components/pagination/fixtures.json +16 -16
  112. data/node_modules/govuk-frontend/govuk/components/pagination/macro-options.json +1 -1
  113. data/node_modules/govuk-frontend/govuk/components/panel/fixtures.json +10 -10
  114. data/node_modules/govuk-frontend/govuk/components/panel/macro-options.json +1 -1
  115. data/node_modules/govuk-frontend/govuk/components/phase-banner/fixtures.json +1 -1
  116. data/node_modules/govuk-frontend/govuk/components/phase-banner/macro-options.json +1 -1
  117. data/node_modules/govuk-frontend/govuk/components/radios/_index.scss +5 -5
  118. data/node_modules/govuk-frontend/govuk/components/radios/fixtures.json +46 -46
  119. data/node_modules/govuk-frontend/govuk/components/radios/macro-options.json +1 -1
  120. data/node_modules/govuk-frontend/govuk/components/radios/radios.js +65 -22
  121. data/node_modules/govuk-frontend/govuk/components/radios/radios.js.map +1 -1
  122. data/node_modules/govuk-frontend/govuk/components/radios/template.njk +2 -2
  123. data/node_modules/govuk-frontend/govuk/components/select/_index.scss +7 -1
  124. data/node_modules/govuk-frontend/govuk/components/select/fixtures.json +19 -20
  125. data/node_modules/govuk-frontend/govuk/components/select/macro-options.json +7 -1
  126. data/node_modules/govuk-frontend/govuk/components/select/template.njk +5 -2
  127. data/node_modules/govuk-frontend/govuk/components/skip-link/fixtures.json +1 -1
  128. data/node_modules/govuk-frontend/govuk/components/skip-link/macro-options.json +1 -1
  129. data/node_modules/govuk-frontend/govuk/components/skip-link/skip-link.js +41 -13
  130. data/node_modules/govuk-frontend/govuk/components/skip-link/skip-link.js.map +1 -1
  131. data/node_modules/govuk-frontend/govuk/components/summary-list/fixtures.json +34 -34
  132. data/node_modules/govuk-frontend/govuk/components/summary-list/macro-options.json +1 -1
  133. data/node_modules/govuk-frontend/govuk/components/table/fixtures.json +21 -21
  134. data/node_modules/govuk-frontend/govuk/components/table/macro-options.json +1 -1
  135. data/node_modules/govuk-frontend/govuk/components/tabs/fixtures.json +15 -15
  136. data/node_modules/govuk-frontend/govuk/components/tabs/macro-options.json +1 -1
  137. data/node_modules/govuk-frontend/govuk/components/tabs/tabs.js +178 -60
  138. data/node_modules/govuk-frontend/govuk/components/tabs/tabs.js.map +1 -1
  139. data/node_modules/govuk-frontend/govuk/components/tabs/template.njk +1 -1
  140. data/node_modules/govuk-frontend/govuk/components/tag/_index.scss +18 -18
  141. data/node_modules/govuk-frontend/govuk/components/tag/fixtures.json +1 -1
  142. data/node_modules/govuk-frontend/govuk/components/tag/macro-options.json +1 -1
  143. data/node_modules/govuk-frontend/govuk/components/textarea/_index.scss +8 -1
  144. data/node_modules/govuk-frontend/govuk/components/textarea/fixtures.json +18 -18
  145. data/node_modules/govuk-frontend/govuk/components/textarea/macro-options.json +7 -1
  146. data/node_modules/govuk-frontend/govuk/components/textarea/template.njk +2 -1
  147. data/node_modules/govuk-frontend/govuk/components/warning-text/fixtures.json +9 -5
  148. data/node_modules/govuk-frontend/govuk/components/warning-text/macro-options.json +3 -3
  149. data/node_modules/govuk-frontend/govuk/components/warning-text/template.njk +1 -1
  150. data/node_modules/govuk-frontend/govuk/core/_all.scss +1 -0
  151. data/node_modules/govuk-frontend/govuk/core/_govuk-frontend-version.scss +5 -0
  152. data/node_modules/govuk-frontend/govuk/helpers/_colour.scss +5 -2
  153. data/node_modules/govuk-frontend/govuk/helpers/_focused.scss +1 -1
  154. data/node_modules/govuk-frontend/govuk/helpers/_font-faces.scss +1 -1
  155. data/node_modules/govuk-frontend/govuk/i18n.js +38 -30
  156. data/node_modules/govuk-frontend/govuk/i18n.js.map +1 -1
  157. data/node_modules/govuk-frontend/govuk/macros/i18n.njk +12 -11
  158. data/node_modules/govuk-frontend/govuk/objects/_width-container.scss +1 -1
  159. data/node_modules/govuk-frontend/govuk/settings/_colours-organisations.scss +4 -0
  160. data/node_modules/govuk-frontend/govuk/settings/_ie8.scss +16 -0
  161. data/node_modules/govuk-frontend/govuk/settings/_links.scss +5 -1
  162. data/node_modules/govuk-frontend/govuk/tools/_ie8.scss +38 -2
  163. data/node_modules/govuk-frontend/govuk/vendor/polyfills/DOMTokenList.js +2 -1
  164. data/node_modules/govuk-frontend/govuk/vendor/polyfills/DOMTokenList.js.map +1 -1
  165. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Date/now.js +2 -1
  166. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Date/now.js.map +1 -1
  167. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Document.js +2 -1
  168. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Document.js.map +1 -1
  169. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/classList.js +10 -3
  170. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/classList.js.map +1 -1
  171. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/closest.js +4 -1
  172. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/closest.js.map +1 -1
  173. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/dataset.js +13 -7
  174. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/dataset.js.map +1 -1
  175. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/matches.js +2 -1
  176. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/matches.js.map +1 -1
  177. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/nextElementSibling.js +8 -2
  178. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/nextElementSibling.js.map +1 -1
  179. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/previousElementSibling.js +8 -2
  180. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/previousElementSibling.js.map +1 -1
  181. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element.js +4 -1
  182. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element.js.map +1 -1
  183. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Event.js +10 -3
  184. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Event.js.map +1 -1
  185. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Function/prototype/bind.js +4 -1
  186. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Function/prototype/bind.js.map +1 -1
  187. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Object/defineProperty.js +2 -1
  188. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Object/defineProperty.js.map +1 -1
  189. data/node_modules/govuk-frontend/govuk/vendor/polyfills/String/prototype/trim.js +3 -2
  190. data/node_modules/govuk-frontend/govuk/vendor/polyfills/String/prototype/trim.js.map +1 -1
  191. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Window.js +2 -1
  192. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Window.js.map +1 -1
  193. data/node_modules/govuk-frontend/govuk-esm/all.mjs +81 -60
  194. data/node_modules/govuk-frontend/govuk-esm/all.mjs.map +1 -0
  195. data/node_modules/govuk-frontend/govuk-esm/common/closest-attribute-value.mjs +12 -8
  196. data/node_modules/govuk-frontend/govuk-esm/common/closest-attribute-value.mjs.map +1 -0
  197. data/node_modules/govuk-frontend/govuk-esm/common/govuk-frontend-version.mjs +9 -0
  198. data/node_modules/govuk-frontend/govuk-esm/common/govuk-frontend-version.mjs.map +1 -0
  199. data/node_modules/govuk-frontend/govuk-esm/common/index.mjs +44 -29
  200. data/node_modules/govuk-frontend/govuk-esm/common/index.mjs.map +1 -0
  201. data/node_modules/govuk-frontend/govuk-esm/common/normalise-dataset.mjs +15 -9
  202. data/node_modules/govuk-frontend/govuk-esm/common/normalise-dataset.mjs.map +1 -0
  203. data/node_modules/govuk-frontend/govuk-esm/common.mjs +3 -5
  204. data/node_modules/govuk-frontend/govuk-esm/common.mjs.map +1 -0
  205. data/node_modules/govuk-frontend/govuk-esm/components/accordion/accordion.mjs +319 -211
  206. data/node_modules/govuk-frontend/govuk-esm/components/accordion/accordion.mjs.map +1 -0
  207. data/node_modules/govuk-frontend/govuk-esm/components/button/button.mjs +47 -30
  208. data/node_modules/govuk-frontend/govuk-esm/components/button/button.mjs.map +1 -0
  209. data/node_modules/govuk-frontend/govuk-esm/components/character-count/character-count.mjs +169 -115
  210. data/node_modules/govuk-frontend/govuk-esm/components/character-count/character-count.mjs.map +1 -0
  211. data/node_modules/govuk-frontend/govuk-esm/components/checkboxes/checkboxes.mjs +88 -51
  212. data/node_modules/govuk-frontend/govuk-esm/components/checkboxes/checkboxes.mjs.map +1 -0
  213. data/node_modules/govuk-frontend/govuk-esm/components/details/details.mjs +64 -54
  214. data/node_modules/govuk-frontend/govuk-esm/components/details/details.mjs.map +1 -0
  215. data/node_modules/govuk-frontend/govuk-esm/components/error-summary/error-summary.mjs +69 -50
  216. data/node_modules/govuk-frontend/govuk-esm/components/error-summary/error-summary.mjs.map +1 -0
  217. data/node_modules/govuk-frontend/govuk-esm/components/header/header.mjs +59 -35
  218. data/node_modules/govuk-frontend/govuk-esm/components/header/header.mjs.map +1 -0
  219. data/node_modules/govuk-frontend/govuk-esm/components/notification-banner/notification-banner.mjs +36 -25
  220. data/node_modules/govuk-frontend/govuk-esm/components/notification-banner/notification-banner.mjs.map +1 -0
  221. data/node_modules/govuk-frontend/govuk-esm/components/radios/radios.mjs +67 -38
  222. data/node_modules/govuk-frontend/govuk-esm/components/radios/radios.mjs.map +1 -0
  223. data/node_modules/govuk-frontend/govuk-esm/components/skip-link/skip-link.mjs +49 -32
  224. data/node_modules/govuk-frontend/govuk-esm/components/skip-link/skip-link.mjs.map +1 -0
  225. data/node_modules/govuk-frontend/govuk-esm/components/tabs/tabs.mjs +263 -163
  226. data/node_modules/govuk-frontend/govuk-esm/components/tabs/tabs.mjs.map +1 -0
  227. data/node_modules/govuk-frontend/govuk-esm/i18n.mjs +68 -57
  228. data/node_modules/govuk-frontend/govuk-esm/i18n.mjs.map +1 -0
  229. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/DOMTokenList.mjs +5 -3
  230. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/DOMTokenList.mjs.map +1 -0
  231. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Date/now.mjs +4 -2
  232. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Date/now.mjs.map +1 -0
  233. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Document.mjs +4 -2
  234. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Document.mjs.map +1 -0
  235. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/classList.mjs +7 -4
  236. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/classList.mjs.map +1 -0
  237. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/closest.mjs +5 -2
  238. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/closest.mjs.map +1 -0
  239. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/dataset.mjs +13 -10
  240. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/dataset.mjs.map +1 -0
  241. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/matches.mjs +4 -2
  242. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/matches.mjs.map +1 -0
  243. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/nextElementSibling.mjs +6 -3
  244. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/nextElementSibling.mjs.map +1 -0
  245. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/previousElementSibling.mjs +6 -3
  246. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/previousElementSibling.mjs.map +1 -0
  247. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element.mjs +5 -2
  248. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element.mjs.map +1 -0
  249. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Event.mjs +7 -4
  250. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Event.mjs.map +1 -0
  251. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Function/prototype/bind.mjs +5 -2
  252. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Function/prototype/bind.mjs.map +1 -0
  253. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Object/defineProperty.mjs +4 -2
  254. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Object/defineProperty.mjs.map +1 -0
  255. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/String/prototype/trim.mjs +5 -3
  256. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/String/prototype/trim.mjs.map +1 -0
  257. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Window.mjs +4 -2
  258. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Window.mjs.map +1 -0
  259. data/node_modules/govuk-frontend/govuk-prototype-kit/init.js +1 -0
  260. data/node_modules/govuk-frontend/govuk-prototype-kit.config.json +2 -1
  261. data/node_modules/govuk-frontend/package.json +3 -2
  262. metadata +43 -6
  263. /data/app/assets/images/govuk_publishing_components/crests/{dit_crest_13px.png → dbt_crest_13px.png} +0 -0
  264. /data/app/assets/images/govuk_publishing_components/crests/{dit_crest_13px_x2.png → dbt_crest_13px_x2.png} +0 -0
  265. /data/app/assets/images/govuk_publishing_components/crests/{dit_crest_18px.png → dbt_crest_18px.png} +0 -0
  266. /data/app/assets/images/govuk_publishing_components/crests/{dit_crest_18px_x2.png → dbt_crest_18px_x2.png} +0 -0
@@ -19,8 +19,10 @@
19
19
  * This seems to fail in IE8, requires more investigation.
20
20
  * See: https://github.com/imagitama/nodelist-foreach-polyfill
21
21
  *
22
- * @param {NodeListOf<Element>} nodes - NodeList from querySelectorAll()
23
- * @param {nodeListIterator} callback - Callback function to run for each node
22
+ * @deprecated Will be made private in v5.0
23
+ * @template {Node} ElementType
24
+ * @param {NodeListOf<ElementType>} nodes - NodeList from querySelectorAll()
25
+ * @param {nodeListIterator<ElementType>} callback - Callback function to run for each node
24
26
  * @returns {void}
25
27
  */
26
28
  function nodeListForEach (nodes, callback) {
@@ -39,6 +41,7 @@
39
41
  * (e.g. {'i18n.showSection': 'Show section'}) and combines them together, with
40
42
  * greatest priority on the LAST item passed in.
41
43
  *
44
+ * @deprecated Will be made private in v5.0
42
45
  * @returns {Object<string, unknown>} A flattened object of key-value pairs.
43
46
  */
44
47
  function mergeConfigs (/* configObject1, configObject2, ...configObjects */) {
@@ -53,6 +56,7 @@
53
56
  */
54
57
  var flattenObject = function (configObject) {
55
58
  // Prepare an empty return object
59
+ /** @type {Object<string, unknown>} */
56
60
  var flattenedObject = {};
57
61
 
58
62
  /**
@@ -89,6 +93,7 @@
89
93
  };
90
94
 
91
95
  // Start with an empty object as our base
96
+ /** @type {Object<string, unknown>} */
92
97
  var formattedConfigObject = {};
93
98
 
94
99
  // Loop through each of the remaining passed objects and push their keys
@@ -110,6 +115,7 @@
110
115
  * Extracts keys starting with a particular namespace from a flattened config
111
116
  * object, removing the namespace in the process.
112
117
  *
118
+ * @deprecated Will be made private in v5.0
113
119
  * @param {Object<string, unknown>} configObject - The object to extract key-value pairs from.
114
120
  * @param {string} namespace - The namespace to filter keys with.
115
121
  * @returns {Object<string, unknown>} Flattened object with dot-separated key namespace removed
@@ -121,10 +127,14 @@
121
127
  if (!configObject || typeof configObject !== 'object') {
122
128
  throw new Error('Provide a `configObject` of type "object".')
123
129
  }
130
+
124
131
  if (!namespace || typeof namespace !== 'string') {
125
132
  throw new Error('Provide a `namespace` of type "string" to filter the `configObject` by.')
126
133
  }
134
+
135
+ /** @type {Object<string, unknown>} */
127
136
  var newObject = {};
137
+
128
138
  for (var key in configObject) {
129
139
  // Split the key into parts, using . as our namespace separator
130
140
  var keyParts = key.split('.');
@@ -145,14 +155,16 @@
145
155
  }
146
156
 
147
157
  /**
158
+ * @template {Node} ElementType
148
159
  * @callback nodeListIterator
149
- * @param {Element} value - The current node being iterated on
160
+ * @param {ElementType} value - The current node being iterated on
150
161
  * @param {number} index - The current index in the iteration
151
- * @param {NodeListOf<Element>} nodes - NodeList from querySelectorAll()
162
+ * @param {NodeListOf<ElementType>} nodes - NodeList from querySelectorAll()
152
163
  * @returns {void}
153
164
  */
154
165
 
155
- (function(undefined) {
166
+ // @ts-nocheck
167
+ (function (undefined) {
156
168
 
157
169
  // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Object/defineProperty/detect.js
158
170
  var detect = (
@@ -239,7 +251,8 @@
239
251
  })
240
252
  .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
241
253
 
242
- (function(undefined) {
254
+ // @ts-nocheck
255
+ (function (undefined) {
243
256
 
244
257
  // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Document/detect.js
245
258
  var detect = ("Document" in this);
@@ -266,6 +279,8 @@
266
279
  })
267
280
  .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
268
281
 
282
+ // @ts-nocheck
283
+
269
284
  (function(undefined) {
270
285
 
271
286
  // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Element/detect.js
@@ -379,6 +394,8 @@
379
394
  })
380
395
  .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
381
396
 
397
+ // @ts-nocheck
398
+
382
399
  (function(undefined) {
383
400
 
384
401
  // Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-library/13cf7c340974d128d557580b5e2dafcd1b1192d1/polyfills/Element/prototype/dataset/detect.js
@@ -399,10 +416,10 @@
399
416
  var element = this;
400
417
  var attributes = this.attributes;
401
418
  var map = {};
402
-
419
+
403
420
  for (var i = 0; i < attributes.length; i++) {
404
421
  var attribute = attributes[i];
405
-
422
+
406
423
  // This regex has been edited from the original polyfill, to add
407
424
  // support for period (.) separators in data-* attribute names. These
408
425
  // are allowed in the HTML spec, but were not covered by the original
@@ -410,11 +427,11 @@
410
427
  if (attribute && attribute.name && (/^data-\w[.\w-]*$/).test(attribute.name)) {
411
428
  var name = attribute.name;
412
429
  var value = attribute.value;
413
-
430
+
414
431
  var propName = name.substr(5).replace(/-./g, function (prop) {
415
432
  return prop.charAt(1).toUpperCase();
416
433
  });
417
-
434
+
418
435
  // If this browser supports __defineGetter__ and __defineSetter__,
419
436
  // continue using defineProperty. If not (like IE 8 and below), we use
420
437
  // a hacky fallback which at least gives an object in the right format
@@ -438,18 +455,19 @@
438
455
 
439
456
  }
440
457
  }
441
-
458
+
442
459
  return map;
443
460
  }
444
461
  });
445
462
 
446
463
  }).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
447
464
 
448
- (function(undefined) {
465
+ // @ts-nocheck
466
+ (function (undefined) {
449
467
 
450
468
  // Detection from https://github.com/mdn/content/blob/cf607d68522cd35ee7670782d3ee3a361eaef2e4/files/en-us/web/javascript/reference/global_objects/string/trim/index.md#polyfill
451
469
  var detect = ('trim' in String.prototype);
452
-
470
+
453
471
  if (detect) return
454
472
 
455
473
  // Polyfill from https://github.com/mdn/content/blob/cf607d68522cd35ee7670782d3ee3a361eaef2e4/files/en-us/web/javascript/reference/global_objects/string/trim/index.md#polyfill
@@ -472,6 +490,7 @@
472
490
  * Designed to be used to convert config passed via data attributes (which are
473
491
  * always strings) into something sensible.
474
492
  *
493
+ * @deprecated Will be made private in v5.0
475
494
  * @param {string} value - The value to normalise
476
495
  * @returns {string | boolean | number | undefined} Normalised data
477
496
  */
@@ -492,7 +511,7 @@
492
511
 
493
512
  // Empty / whitespace-only strings are considered finite so we need to check
494
513
  // the length of the trimmed string as well
495
- if (trimmedValue.length > 0 && isFinite(trimmedValue)) {
514
+ if (trimmedValue.length > 0 && isFinite(Number(trimmedValue))) {
496
515
  return Number(trimmedValue)
497
516
  }
498
517
 
@@ -504,10 +523,12 @@
504
523
  *
505
524
  * Loop over an object and normalise each value using normaliseData function
506
525
  *
526
+ * @deprecated Will be made private in v5.0
507
527
  * @param {DOMStringMap} dataset - HTML element dataset
508
528
  * @returns {Object<string, unknown>} Normalised dataset
509
529
  */
510
530
  function normaliseDataset (dataset) {
531
+ /** @type {Object<string, unknown>} */
511
532
  var out = {};
512
533
 
513
534
  for (var key in dataset) {
@@ -552,17 +573,17 @@
552
573
  }
553
574
 
554
575
  // If the `count` option is set, determine which plural suffix is needed and
555
- // change the lookupKey to match. We check to see if it's undefined instead of
576
+ // change the lookupKey to match. We check to see if it's numeric instead of
556
577
  // falsy, as this could legitimately be 0.
557
- if (options && typeof options.count !== 'undefined') {
578
+ if (options && typeof options.count === 'number') {
558
579
  // Get the plural suffix
559
580
  lookupKey = lookupKey + '.' + this.getPluralSuffix(lookupKey, options.count);
560
581
  }
561
582
 
562
- if (lookupKey in this.translations) {
563
- // Fetch the translation string for that lookup key
564
- var translationString = this.translations[lookupKey];
583
+ // Fetch the translation string for that lookup key
584
+ var translationString = this.translations[lookupKey];
565
585
 
586
+ if (typeof translationString === 'string') {
566
587
  // Check for ${} placeholders in the translation string
567
588
  if (translationString.match(/%{(.\S+)}/)) {
568
589
  if (!options) {
@@ -589,32 +610,46 @@
589
610
  * @returns {string} The translation string to output, with ${} placeholders replaced
590
611
  */
591
612
  I18n.prototype.replacePlaceholders = function (translationString, options) {
613
+ /** @type {Intl.NumberFormat | undefined} */
592
614
  var formatter;
593
615
 
594
616
  if (this.hasIntlNumberFormatSupport()) {
595
617
  formatter = new Intl.NumberFormat(this.locale);
596
618
  }
597
619
 
598
- return translationString.replace(/%{(.\S+)}/g, function (placeholderWithBraces, placeholderKey) {
599
- if (Object.prototype.hasOwnProperty.call(options, placeholderKey)) {
600
- var placeholderValue = options[placeholderKey];
620
+ return translationString.replace(
621
+ /%{(.\S+)}/g,
601
622
 
602
- // If a user has passed `false` as the value for the placeholder
603
- // treat it as though the value should not be displayed
604
- if (placeholderValue === false) {
605
- return ''
606
- }
623
+ /**
624
+ * Replace translation string placeholders
625
+ *
626
+ * @param {string} placeholderWithBraces - Placeholder with braces
627
+ * @param {string} placeholderKey - Placeholder key
628
+ * @returns {string} Placeholder value
629
+ */
630
+ function (placeholderWithBraces, placeholderKey) {
631
+ if (Object.prototype.hasOwnProperty.call(options, placeholderKey)) {
632
+ var placeholderValue = options[placeholderKey];
633
+
634
+ // If a user has passed `false` as the value for the placeholder
635
+ // treat it as though the value should not be displayed
636
+ if (placeholderValue === false || (
637
+ typeof placeholderValue !== 'number' &&
638
+ typeof placeholderValue !== 'string')
639
+ ) {
640
+ return ''
641
+ }
607
642
 
608
- // If the placeholder's value is a number, localise the number formatting
609
- if (typeof placeholderValue === 'number' && formatter) {
610
- return formatter.format(placeholderValue)
611
- }
643
+ // If the placeholder's value is a number, localise the number formatting
644
+ if (typeof placeholderValue === 'number') {
645
+ return formatter ? formatter.format(placeholderValue) : placeholderValue.toString()
646
+ }
612
647
 
613
- return placeholderValue
614
- } else {
615
- throw new Error('i18n: no data found to replace ' + placeholderWithBraces + ' placeholder in string')
616
- }
617
- })
648
+ return placeholderValue
649
+ } else {
650
+ throw new Error('i18n: no data found to replace ' + placeholderWithBraces + ' placeholder in string')
651
+ }
652
+ })
618
653
  };
619
654
 
620
655
  /**
@@ -730,7 +765,7 @@
730
765
  * regardless of region. There are exceptions, however, (e.g. Portuguese) so
731
766
  * this searches by both the full and shortened locale codes, just to be sure.
732
767
  *
733
- * @returns {PluralRuleName | undefined} The name of the pluralisation rule to use (a key for one
768
+ * @returns {string | undefined} The name of the pluralisation rule to use (a key for one
734
769
  * of the functions in this.pluralRules)
735
770
  */
736
771
  I18n.prototype.getPluralRulesForLocale = function () {
@@ -781,7 +816,7 @@
781
816
  * Spanish: European Portuguese (pt-PT), Italian (it), Spanish (es)
782
817
  * Welsh: Welsh (cy)
783
818
  *
784
- * @type {Object<PluralRuleName, string[]>}
819
+ * @type {Object<string, string[]>}
785
820
  */
786
821
  I18n.pluralRulesMap = {
787
822
  arabic: ['ar'],
@@ -869,12 +904,6 @@
869
904
  /* eslint-enable jsdoc/require-jsdoc */
870
905
  };
871
906
 
872
- /**
873
- * Supported languages for plural rules
874
- *
875
- * @typedef {'arabic' | 'chinese' | 'french' | 'german' | 'irish' | 'russian' | 'scottish' | 'spanish' | 'welsh'} PluralRuleName
876
- */
877
-
878
907
  /**
879
908
  * Plural rule category mnemonic tags
880
909
  *
@@ -896,7 +925,8 @@
896
925
  * @property {string} [many] - Plural form used for many
897
926
  */
898
927
 
899
- (function(undefined) {
928
+ // @ts-nocheck
929
+ (function (undefined) {
900
930
 
901
931
  // Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/master/packages/polyfill-library/polyfills/DOMTokenList/detect.js
902
932
  var detect = (
@@ -1161,6 +1191,8 @@
1161
1191
 
1162
1192
  }).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
1163
1193
 
1194
+ // @ts-nocheck
1195
+
1164
1196
  (function(undefined) {
1165
1197
 
1166
1198
  // Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/8717a9e04ac7aff99b4980fbedead98036b0929a/packages/polyfill-library/polyfills/Element/prototype/classList/detect.js
@@ -1251,7 +1283,8 @@
1251
1283
 
1252
1284
  }).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
1253
1285
 
1254
- (function(undefined) {
1286
+ // @ts-nocheck
1287
+ (function (undefined) {
1255
1288
 
1256
1289
  // Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/1f3c09b402f65bf6e393f933a15ba63f1b86ef1f/packages/polyfill-library/polyfills/Element/prototype/matches/detect.js
1257
1290
  var detect = (
@@ -1275,6 +1308,8 @@
1275
1308
 
1276
1309
  }).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
1277
1310
 
1311
+ // @ts-nocheck
1312
+
1278
1313
  (function(undefined) {
1279
1314
 
1280
1315
  // Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/1f3c09b402f65bf6e393f933a15ba63f1b86ef1f/packages/polyfill-library/polyfills/Element/prototype/closest/detect.js
@@ -1298,7 +1333,8 @@
1298
1333
 
1299
1334
  }).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
1300
1335
 
1301
- (function(undefined) {
1336
+ // @ts-nocheck
1337
+ (function (undefined) {
1302
1338
 
1303
1339
  // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Window/detect.js
1304
1340
  var detect = ('Window' in this);
@@ -1319,6 +1355,8 @@
1319
1355
  })
1320
1356
  .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
1321
1357
 
1358
+ // @ts-nocheck
1359
+
1322
1360
  (function(undefined) {
1323
1361
 
1324
1362
  // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Event/detect.js
@@ -1568,6 +1606,8 @@
1568
1606
  })
1569
1607
  .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
1570
1608
 
1609
+ // @ts-nocheck
1610
+
1571
1611
  (function(undefined) {
1572
1612
  // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Function/prototype/bind/detect.js
1573
1613
  var detect = 'bind' in Function.prototype;
@@ -1756,57 +1796,119 @@
1756
1796
  * attribute, which also provides accessibility.
1757
1797
  *
1758
1798
  * @class
1759
- * @param {HTMLElement} $module - HTML element to use for accordion
1799
+ * @param {Element} $module - HTML element to use for accordion
1760
1800
  * @param {AccordionConfig} [config] - Accordion config
1761
1801
  */
1762
1802
  function Accordion ($module, config) {
1803
+ if (!($module instanceof HTMLElement)) {
1804
+ return this
1805
+ }
1806
+
1807
+ /** @deprecated Will be made private in v5.0 */
1763
1808
  this.$module = $module;
1764
1809
 
1765
1810
  var defaultConfig = {
1766
- i18n: ACCORDION_TRANSLATIONS
1811
+ i18n: ACCORDION_TRANSLATIONS,
1812
+ rememberExpanded: true
1767
1813
  };
1768
1814
 
1815
+ /**
1816
+ * @deprecated Will be made private in v5.0
1817
+ * @type {AccordionConfig}
1818
+ */
1769
1819
  this.config = mergeConfigs(
1770
1820
  defaultConfig,
1771
1821
  config || {},
1772
1822
  normaliseDataset($module.dataset)
1773
1823
  );
1774
1824
 
1825
+ /** @deprecated Will be made private in v5.0 */
1775
1826
  this.i18n = new I18n(extractConfigByNamespace(this.config, 'i18n'));
1776
1827
 
1828
+ /** @deprecated Will be made private in v5.0 */
1777
1829
  this.controlsClass = 'govuk-accordion__controls';
1830
+
1831
+ /** @deprecated Will be made private in v5.0 */
1778
1832
  this.showAllClass = 'govuk-accordion__show-all';
1833
+
1834
+ /** @deprecated Will be made private in v5.0 */
1779
1835
  this.showAllTextClass = 'govuk-accordion__show-all-text';
1780
1836
 
1837
+ /** @deprecated Will be made private in v5.0 */
1781
1838
  this.sectionClass = 'govuk-accordion__section';
1839
+
1840
+ /** @deprecated Will be made private in v5.0 */
1782
1841
  this.sectionExpandedClass = 'govuk-accordion__section--expanded';
1842
+
1843
+ /** @deprecated Will be made private in v5.0 */
1783
1844
  this.sectionButtonClass = 'govuk-accordion__section-button';
1845
+
1846
+ /** @deprecated Will be made private in v5.0 */
1784
1847
  this.sectionHeaderClass = 'govuk-accordion__section-header';
1848
+
1849
+ /** @deprecated Will be made private in v5.0 */
1785
1850
  this.sectionHeadingClass = 'govuk-accordion__section-heading';
1851
+
1852
+ /** @deprecated Will be made private in v5.0 */
1786
1853
  this.sectionHeadingDividerClass = 'govuk-accordion__section-heading-divider';
1854
+
1855
+ /** @deprecated Will be made private in v5.0 */
1787
1856
  this.sectionHeadingTextClass = 'govuk-accordion__section-heading-text';
1857
+
1858
+ /** @deprecated Will be made private in v5.0 */
1788
1859
  this.sectionHeadingTextFocusClass = 'govuk-accordion__section-heading-text-focus';
1789
1860
 
1861
+ /** @deprecated Will be made private in v5.0 */
1790
1862
  this.sectionShowHideToggleClass = 'govuk-accordion__section-toggle';
1863
+
1864
+ /** @deprecated Will be made private in v5.0 */
1791
1865
  this.sectionShowHideToggleFocusClass = 'govuk-accordion__section-toggle-focus';
1866
+
1867
+ /** @deprecated Will be made private in v5.0 */
1792
1868
  this.sectionShowHideTextClass = 'govuk-accordion__section-toggle-text';
1869
+
1870
+ /** @deprecated Will be made private in v5.0 */
1793
1871
  this.upChevronIconClass = 'govuk-accordion-nav__chevron';
1872
+
1873
+ /** @deprecated Will be made private in v5.0 */
1794
1874
  this.downChevronIconClass = 'govuk-accordion-nav__chevron--down';
1795
1875
 
1876
+ /** @deprecated Will be made private in v5.0 */
1796
1877
  this.sectionSummaryClass = 'govuk-accordion__section-summary';
1878
+
1879
+ /** @deprecated Will be made private in v5.0 */
1797
1880
  this.sectionSummaryFocusClass = 'govuk-accordion__section-summary-focus';
1881
+
1882
+ /** @deprecated Will be made private in v5.0 */
1798
1883
  this.sectionContentClass = 'govuk-accordion__section-content';
1799
1884
 
1800
- this.$sections = this.$module.querySelectorAll('.' + this.sectionClass);
1885
+ var $sections = this.$module.querySelectorAll('.' + this.sectionClass);
1886
+ if (!$sections.length) {
1887
+ return this
1888
+ }
1889
+
1890
+ /** @deprecated Will be made private in v5.0 */
1891
+ this.$sections = $sections;
1892
+
1893
+ /** @deprecated Will be made private in v5.0 */
1801
1894
  this.browserSupportsSessionStorage = helper.checkForSessionStorage();
1895
+
1896
+ /** @deprecated Will be made private in v5.0 */
1897
+ this.$showAllButton = null;
1898
+
1899
+ /** @deprecated Will be made private in v5.0 */
1900
+ this.$showAllIcon = null;
1901
+
1902
+ /** @deprecated Will be made private in v5.0 */
1903
+ this.$showAllText = null;
1802
1904
  }
1803
1905
 
1804
1906
  /**
1805
1907
  * Initialise component
1806
1908
  */
1807
1909
  Accordion.prototype.init = function () {
1808
- // Check for module
1809
- if (!this.$module) {
1910
+ // Check that required elements are present
1911
+ if (!this.$module || !this.$sections) {
1810
1912
  return
1811
1913
  }
1812
1914
 
@@ -1820,6 +1922,8 @@
1820
1922
 
1821
1923
  /**
1822
1924
  * Initialise controls and set attributes
1925
+ *
1926
+ * @deprecated Will be made private in v5.0
1823
1927
  */
1824
1928
  Accordion.prototype.initControls = function () {
1825
1929
  // Create "Show all" button and set attributes
@@ -1855,28 +1959,38 @@
1855
1959
 
1856
1960
  /**
1857
1961
  * Initialise section headers
1962
+ *
1963
+ * @deprecated Will be made private in v5.0
1858
1964
  */
1859
1965
  Accordion.prototype.initSectionHeaders = function () {
1860
- // Loop through section headers
1861
- nodeListForEach(this.$sections, function ($section, i) {
1966
+ var $component = this;
1967
+ var $sections = this.$sections;
1968
+
1969
+ // Loop through sections
1970
+ nodeListForEach($sections, function ($section, i) {
1971
+ var $header = $section.querySelector('.' + $component.sectionHeaderClass);
1972
+ if (!$header) {
1973
+ return
1974
+ }
1975
+
1862
1976
  // Set header attributes
1863
- var $header = $section.querySelector('.' + this.sectionHeaderClass);
1864
- this.constructHeaderMarkup($header, i);
1865
- this.setExpanded(this.isExpanded($section), $section);
1977
+ $component.constructHeaderMarkup($header, i);
1978
+ $component.setExpanded($component.isExpanded($section), $section);
1866
1979
 
1867
1980
  // Handle events
1868
- $header.addEventListener('click', this.onSectionToggle.bind(this, $section));
1981
+ $header.addEventListener('click', $component.onSectionToggle.bind($component, $section));
1869
1982
 
1870
1983
  // See if there is any state stored in sessionStorage and set the sections to
1871
1984
  // open or closed.
1872
- this.setInitialState($section);
1873
- }.bind(this));
1985
+ $component.setInitialState($section);
1986
+ });
1874
1987
  };
1875
1988
 
1876
1989
  /**
1877
1990
  * Construct section header
1878
1991
  *
1879
- * @param {HTMLDivElement} $header - Section header
1992
+ * @deprecated Will be made private in v5.0
1993
+ * @param {Element} $header - Section header
1880
1994
  * @param {number} index - Section index
1881
1995
  */
1882
1996
  Accordion.prototype.constructHeaderMarkup = function ($header, index) {
@@ -1884,10 +1998,14 @@
1884
1998
  var $heading = $header.querySelector('.' + this.sectionHeadingClass);
1885
1999
  var $summary = $header.querySelector('.' + this.sectionSummaryClass);
1886
2000
 
2001
+ if (!$span || !$heading) {
2002
+ return
2003
+ }
2004
+
1887
2005
  // Create a button element that will replace the '.govuk-accordion__section-button' span
1888
2006
  var $button = document.createElement('button');
1889
2007
  $button.setAttribute('type', 'button');
1890
- $button.setAttribute('aria-controls', this.$module.id + '-content-' + (index + 1));
2008
+ $button.setAttribute('aria-controls', this.$module.id + '-content-' + (index + 1).toString());
1891
2009
 
1892
2010
  // Copy all attributes (https://developer.mozilla.org/en-US/docs/Web/API/Element/attributes) from $span to $button
1893
2011
  for (var i = 0; i < $span.attributes.length; i++) {
@@ -1941,7 +2059,7 @@
1941
2059
  $button.appendChild(this.getButtonPunctuationEl());
1942
2060
 
1943
2061
  // If summary content exists add to DOM in correct order
1944
- if (typeof ($summary) !== 'undefined' && $summary !== null) {
2062
+ if ($summary) {
1945
2063
  // Create a new `span` element and copy the summary line content from the original `div` to the
1946
2064
  // new `span`
1947
2065
  // This is because the summary line text is now inside a button element, which can only contain
@@ -1978,10 +2096,19 @@
1978
2096
  /**
1979
2097
  * When a section is opened by the user agent via the 'beforematch' event
1980
2098
  *
2099
+ * @deprecated Will be made private in v5.0
1981
2100
  * @param {Event} event - Generic event
1982
2101
  */
1983
2102
  Accordion.prototype.onBeforeMatch = function (event) {
1984
- var $section = event.target.closest('.' + this.sectionClass);
2103
+ var $fragment = event.target;
2104
+
2105
+ // Handle elements with `.closest()` support only
2106
+ if (!($fragment instanceof Element)) {
2107
+ return
2108
+ }
2109
+
2110
+ // Handle when fragment is inside section
2111
+ var $section = $fragment.closest('.' + this.sectionClass);
1985
2112
  if ($section) {
1986
2113
  this.setExpanded(true, $section);
1987
2114
  }
@@ -1990,7 +2117,8 @@
1990
2117
  /**
1991
2118
  * When section toggled, set and store state
1992
2119
  *
1993
- * @param {HTMLElement} $section - Section element
2120
+ * @deprecated Will be made private in v5.0
2121
+ * @param {Element} $section - Section element
1994
2122
  */
1995
2123
  Accordion.prototype.onSectionToggle = function ($section) {
1996
2124
  var expanded = this.isExpanded($section);
@@ -2002,26 +2130,31 @@
2002
2130
 
2003
2131
  /**
2004
2132
  * When Open/Close All toggled, set and store state
2133
+ *
2134
+ * @deprecated Will be made private in v5.0
2005
2135
  */
2006
2136
  Accordion.prototype.onShowOrHideAllToggle = function () {
2007
- var $module = this;
2137
+ var $component = this;
2008
2138
  var $sections = this.$sections;
2139
+
2009
2140
  var nowExpanded = !this.checkIfAllSectionsOpen();
2010
2141
 
2142
+ // Loop through sections
2011
2143
  nodeListForEach($sections, function ($section) {
2012
- $module.setExpanded(nowExpanded, $section);
2144
+ $component.setExpanded(nowExpanded, $section);
2013
2145
  // Store the state in sessionStorage when a change is triggered
2014
- $module.storeState($section);
2146
+ $component.storeState($section);
2015
2147
  });
2016
2148
 
2017
- $module.updateShowAllButton(nowExpanded);
2149
+ $component.updateShowAllButton(nowExpanded);
2018
2150
  };
2019
2151
 
2020
2152
  /**
2021
2153
  * Set section attributes when opened/closed
2022
2154
  *
2155
+ * @deprecated Will be made private in v5.0
2023
2156
  * @param {boolean} expanded - Section expanded
2024
- * @param {HTMLElement} $section - Section element
2157
+ * @param {Element} $section - Section element
2025
2158
  */
2026
2159
  Accordion.prototype.setExpanded = function (expanded, $section) {
2027
2160
  var $showHideIcon = $section.querySelector('.' + this.upChevronIconClass);
@@ -2029,23 +2162,30 @@
2029
2162
  var $button = $section.querySelector('.' + this.sectionButtonClass);
2030
2163
  var $content = $section.querySelector('.' + this.sectionContentClass);
2031
2164
 
2165
+ if (!$showHideIcon ||
2166
+ !($showHideText instanceof HTMLElement) ||
2167
+ !$button ||
2168
+ !$content) {
2169
+ return
2170
+ }
2171
+
2032
2172
  var newButtonText = expanded
2033
2173
  ? this.i18n.t('hideSection')
2034
2174
  : this.i18n.t('showSection');
2035
2175
 
2036
2176
  $showHideText.innerText = newButtonText;
2037
- $button.setAttribute('aria-expanded', expanded);
2177
+ $button.setAttribute('aria-expanded', expanded.toString());
2038
2178
 
2039
2179
  // Update aria-label combining
2040
2180
  var ariaLabelParts = [];
2041
2181
 
2042
2182
  var $headingText = $section.querySelector('.' + this.sectionHeadingTextClass);
2043
- if ($headingText) {
2183
+ if ($headingText instanceof HTMLElement) {
2044
2184
  ariaLabelParts.push($headingText.innerText.trim());
2045
2185
  }
2046
2186
 
2047
2187
  var $summary = $section.querySelector('.' + this.sectionSummaryClass);
2048
- if ($summary) {
2188
+ if ($summary instanceof HTMLElement) {
2049
2189
  ariaLabelParts.push($summary.innerText.trim());
2050
2190
  }
2051
2191
 
@@ -2080,7 +2220,8 @@
2080
2220
  /**
2081
2221
  * Get state of section
2082
2222
  *
2083
- * @param {HTMLElement} $section - Section element
2223
+ * @deprecated Will be made private in v5.0
2224
+ * @param {Element} $section - Section element
2084
2225
  * @returns {boolean} True if expanded
2085
2226
  */
2086
2227
  Accordion.prototype.isExpanded = function ($section) {
@@ -2090,6 +2231,7 @@
2090
2231
  /**
2091
2232
  * Check if all sections are open
2092
2233
  *
2234
+ * @deprecated Will be made private in v5.0
2093
2235
  * @returns {boolean} True if all sections are open
2094
2236
  */
2095
2237
  Accordion.prototype.checkIfAllSectionsOpen = function () {
@@ -2105,6 +2247,7 @@
2105
2247
  /**
2106
2248
  * Update "Show all sections" button
2107
2249
  *
2250
+ * @deprecated Will be made private in v5.0
2108
2251
  * @param {boolean} expanded - Section expanded
2109
2252
  */
2110
2253
  Accordion.prototype.updateShowAllButton = function (expanded) {
@@ -2112,7 +2255,7 @@
2112
2255
  ? this.i18n.t('hideAllSections')
2113
2256
  : this.i18n.t('showAllSections');
2114
2257
 
2115
- this.$showAllButton.setAttribute('aria-expanded', expanded);
2258
+ this.$showAllButton.setAttribute('aria-expanded', expanded.toString());
2116
2259
  this.$showAllText.innerText = newButtonText;
2117
2260
 
2118
2261
  // Swap icon, toggle class
@@ -2146,10 +2289,11 @@
2146
2289
  /**
2147
2290
  * Set the state of the accordions in sessionStorage
2148
2291
  *
2149
- * @param {HTMLElement} $section - Section element
2292
+ * @deprecated Will be made private in v5.0
2293
+ * @param {Element} $section - Section element
2150
2294
  */
2151
2295
  Accordion.prototype.storeState = function ($section) {
2152
- if (this.browserSupportsSessionStorage) {
2296
+ if (this.browserSupportsSessionStorage && this.config.rememberExpanded) {
2153
2297
  // We need a unique way of identifying each content in the Accordion. Since
2154
2298
  // an `#id` should be unique and an `id` is required for `aria-` attributes
2155
2299
  // `id` can be safely used.
@@ -2170,10 +2314,11 @@
2170
2314
  /**
2171
2315
  * Read the state of the accordions from sessionStorage
2172
2316
  *
2173
- * @param {HTMLElement} $section - Section element
2317
+ * @deprecated Will be made private in v5.0
2318
+ * @param {Element} $section - Section element
2174
2319
  */
2175
2320
  Accordion.prototype.setInitialState = function ($section) {
2176
- if (this.browserSupportsSessionStorage) {
2321
+ if (this.browserSupportsSessionStorage && this.config.rememberExpanded) {
2177
2322
  var $button = $section.querySelector('.' + this.sectionButtonClass);
2178
2323
 
2179
2324
  if ($button) {
@@ -2194,7 +2339,8 @@
2194
2339
  * into thematic chunks.
2195
2340
  * See https://github.com/alphagov/govuk-frontend/issues/2327#issuecomment-922957442
2196
2341
  *
2197
- * @returns {HTMLElement} DOM element
2342
+ * @deprecated Will be made private in v5.0
2343
+ * @returns {Element} DOM element
2198
2344
  */
2199
2345
  Accordion.prototype.getButtonPunctuationEl = function () {
2200
2346
  var $punctuationEl = document.createElement('span');
@@ -2208,6 +2354,8 @@
2208
2354
  *
2209
2355
  * @typedef {object} AccordionConfig
2210
2356
  * @property {AccordionTranslations} [i18n = ACCORDION_TRANSLATIONS] - See constant {@link ACCORDION_TRANSLATIONS}
2357
+ * @property {boolean} [rememberExpanded] - Whether the expanded and collapsed
2358
+ * state of each section is remembered and restored when navigating.
2211
2359
  */
2212
2360
 
2213
2361
  /**
@@ -2219,17 +2367,17 @@
2219
2367
  * the visible text shown on screen, and text to help assistive technology users
2220
2368
  * for the buttons toggling each section.
2221
2369
  * @property {string} [hideAllSections] - The text content for the 'Hide all
2222
- * sections' button, used when at least one section is expanded.
2370
+ * sections' button, used when at least one section is expanded.
2223
2371
  * @property {string} [hideSection] - The text content for the 'Hide'
2224
- * button, used when a section is expanded.
2372
+ * button, used when a section is expanded.
2225
2373
  * @property {string} [hideSectionAriaLabel] - The text content appended to the
2226
- * 'Hide' button's accessible name when a section is expanded.
2374
+ * 'Hide' button's accessible name when a section is expanded.
2227
2375
  * @property {string} [showAllSections] - The text content for the 'Show all
2228
- * sections' button, used when all sections are collapsed.
2376
+ * sections' button, used when all sections are collapsed.
2229
2377
  * @property {string} [showSection] - The text content for the 'Show'
2230
- * button, used when a section is collapsed.
2378
+ * button, used when a section is collapsed.
2231
2379
  * @property {string} [showSectionAriaLabel] - The text content appended to the
2232
- * 'Show' button's accessible name when a section is expanded.
2380
+ * 'Show' button's accessible name when a section is expanded.
2233
2381
  */
2234
2382
 
2235
2383
  return Accordion;