govuk_publishing_components 32.1.0 → 33.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/component_guide/accessibility-test.js +0 -1
  3. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-core.js +175 -0
  4. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-ecommerce-tracker.js +4 -4
  5. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-event-tracker.js +5 -13
  6. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-link-tracker.js +80 -309
  7. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-page-views.js +2 -2
  8. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-specialist-link-tracker.js +140 -0
  9. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/init-ga4.js +3 -0
  10. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4.js +1 -0
  11. data/app/assets/javascripts/govuk_publishing_components/components/accordion.js +12 -1
  12. data/app/assets/javascripts/govuk_publishing_components/components/single-page-notification-button.js +24 -8
  13. data/app/assets/javascripts/govuk_publishing_components/components/step-by-step-nav.js +22 -1
  14. data/app/assets/javascripts/govuk_publishing_components/vendor/lux/lux-reporter.js +140 -191
  15. data/app/assets/stylesheets/govuk_publishing_components/components/_big-number.scss +2 -5
  16. data/app/assets/stylesheets/govuk_publishing_components/components/_image-card.scss +1 -5
  17. data/app/assets/stylesheets/govuk_publishing_components/components/_input.scss +3 -5
  18. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-super-navigation-header.scss +10 -30
  19. data/app/assets/stylesheets/govuk_publishing_components/components/_search.scss +0 -7
  20. data/app/views/govuk_publishing_components/components/_accordion.html.erb +14 -1
  21. data/app/views/govuk_publishing_components/components/_error_summary.html.erb +27 -26
  22. data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +2 -2
  23. data/app/views/govuk_publishing_components/components/_phase_banner.html.erb +1 -1
  24. data/app/views/govuk_publishing_components/components/_share_links.html.erb +11 -13
  25. data/app/views/govuk_publishing_components/components/_single_page_notification_button.html.erb +1 -1
  26. data/app/views/govuk_publishing_components/components/_step_by_step_nav.html.erb +4 -1
  27. data/app/views/govuk_publishing_components/components/docs/accordion.yml +15 -3
  28. data/app/views/govuk_publishing_components/components/docs/button.yml +10 -0
  29. data/app/views/govuk_publishing_components/components/docs/share_links.yml +59 -30
  30. data/app/views/govuk_publishing_components/components/docs/single_page_notification_button.yml +10 -1
  31. data/app/views/govuk_publishing_components/components/docs/step_by_step_nav.yml +34 -0
  32. data/app/views/govuk_publishing_components/components/feedback/_problem_form.html.erb +1 -1
  33. data/app/views/govuk_publishing_components/components/feedback/_survey_signup_form.html.erb +1 -1
  34. data/app/views/govuk_publishing_components/components/feedback/_yes_no_banner.html.erb +3 -3
  35. data/lib/govuk_publishing_components/presenters/button_helper.rb +9 -2
  36. data/lib/govuk_publishing_components/presenters/single_page_notification_button_helper.rb +25 -1
  37. data/lib/govuk_publishing_components/version.rb +1 -1
  38. data/node_modules/axe-core/axe.js +4559 -4673
  39. data/node_modules/axe-core/axe.min.js +2 -2
  40. data/node_modules/axe-core/package.json +2 -2
  41. data/node_modules/axe-core/sri-history.json +4 -0
  42. data/node_modules/govuk-frontend/README.md +1 -2
  43. data/node_modules/govuk-frontend/govuk/all.js +1398 -273
  44. data/node_modules/govuk-frontend/govuk/common/closest-attribute-value.js +70 -0
  45. data/node_modules/govuk-frontend/govuk/common/index.js +172 -0
  46. data/node_modules/govuk-frontend/govuk/common/normalise-dataset.js +373 -0
  47. data/node_modules/govuk-frontend/govuk/common.js +138 -3
  48. data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js +753 -25
  49. data/node_modules/govuk-frontend/govuk/components/accordion/fixtures.json +54 -22
  50. data/node_modules/govuk-frontend/govuk/components/accordion/macro-options.json +36 -0
  51. data/node_modules/govuk-frontend/govuk/components/accordion/template.njk +7 -1
  52. data/node_modules/govuk-frontend/govuk/components/back-link/fixtures.json +12 -12
  53. data/node_modules/govuk-frontend/govuk/components/breadcrumbs/fixtures.json +22 -22
  54. data/node_modules/govuk-frontend/govuk/components/button/_index.scss +23 -5
  55. data/node_modules/govuk-frontend/govuk/components/button/button.js +365 -107
  56. data/node_modules/govuk-frontend/govuk/components/button/fixtures.json +85 -66
  57. data/node_modules/govuk-frontend/govuk/components/button/template.njk +1 -1
  58. data/node_modules/govuk-frontend/govuk/components/character-count/_index.scss +9 -0
  59. data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +1033 -121
  60. data/node_modules/govuk-frontend/govuk/components/character-count/fixtures.json +112 -36
  61. data/node_modules/govuk-frontend/govuk/components/character-count/macro-options.json +42 -0
  62. data/node_modules/govuk-frontend/govuk/components/character-count/template.njk +27 -3
  63. data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js +30 -2
  64. data/node_modules/govuk-frontend/govuk/components/checkboxes/fixtures.json +96 -93
  65. data/node_modules/govuk-frontend/govuk/components/cookie-banner/fixtures.json +46 -46
  66. data/node_modules/govuk-frontend/govuk/components/date-input/fixtures.json +50 -50
  67. data/node_modules/govuk-frontend/govuk/components/details/details.js +43 -13
  68. data/node_modules/govuk-frontend/govuk/components/details/fixtures.json +20 -20
  69. data/node_modules/govuk-frontend/govuk/components/error-message/fixtures.json +20 -20
  70. data/node_modules/govuk-frontend/govuk/components/error-summary/error-summary.js +268 -6
  71. data/node_modules/govuk-frontend/govuk/components/error-summary/fixtures.json +44 -35
  72. data/node_modules/govuk-frontend/govuk/components/error-summary/template.njk +25 -21
  73. data/node_modules/govuk-frontend/govuk/components/fieldset/fixtures.json +51 -39
  74. data/node_modules/govuk-frontend/govuk/components/file-upload/fixtures.json +26 -26
  75. data/node_modules/govuk-frontend/govuk/components/footer/_index.scss +1 -1
  76. data/node_modules/govuk-frontend/govuk/components/footer/fixtures.json +46 -46
  77. data/node_modules/govuk-frontend/govuk/components/footer/macro-options.json +2 -2
  78. data/node_modules/govuk-frontend/govuk/components/header/fixtures.json +93 -38
  79. data/node_modules/govuk-frontend/govuk/components/header/header.js +6 -0
  80. data/node_modules/govuk-frontend/govuk/components/header/macro-options.json +8 -2
  81. data/node_modules/govuk-frontend/govuk/components/header/template.njk +4 -2
  82. data/node_modules/govuk-frontend/govuk/components/hint/fixtures.json +12 -12
  83. data/node_modules/govuk-frontend/govuk/components/input/fixtures.json +80 -80
  84. data/node_modules/govuk-frontend/govuk/components/inset-text/fixtures.json +12 -12
  85. data/node_modules/govuk-frontend/govuk/components/label/fixtures.json +34 -34
  86. data/node_modules/govuk-frontend/govuk/components/notification-banner/fixtures.json +56 -46
  87. data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js +252 -2
  88. data/node_modules/govuk-frontend/govuk/components/notification-banner/template.njk +1 -1
  89. data/node_modules/govuk-frontend/govuk/components/pagination/_index.scss +10 -7
  90. data/node_modules/govuk-frontend/govuk/components/pagination/fixtures.json +33 -26
  91. data/node_modules/govuk-frontend/govuk/components/panel/fixtures.json +18 -18
  92. data/node_modules/govuk-frontend/govuk/components/phase-banner/fixtures.json +14 -14
  93. data/node_modules/govuk-frontend/govuk/components/radios/fixtures.json +94 -91
  94. data/node_modules/govuk-frontend/govuk/components/radios/radios.js +30 -2
  95. data/node_modules/govuk-frontend/govuk/components/select/fixtures.json +32 -32
  96. data/node_modules/govuk-frontend/govuk/components/skip-link/fixtures.json +22 -20
  97. data/node_modules/govuk-frontend/govuk/components/skip-link/skip-link.js +10 -4
  98. data/node_modules/govuk-frontend/govuk/components/summary-list/fixtures.json +50 -50
  99. data/node_modules/govuk-frontend/govuk/components/table/_index.scss +1 -1
  100. data/node_modules/govuk-frontend/govuk/components/table/fixtures.json +40 -40
  101. data/node_modules/govuk-frontend/govuk/components/tabs/fixtures.json +29 -29
  102. data/node_modules/govuk-frontend/govuk/components/tabs/tabs.js +28 -0
  103. data/node_modules/govuk-frontend/govuk/components/tag/fixtures.json +28 -28
  104. data/node_modules/govuk-frontend/govuk/components/textarea/fixtures.json +34 -34
  105. data/node_modules/govuk-frontend/govuk/components/warning-text/fixtures.json +14 -14
  106. data/node_modules/govuk-frontend/govuk/core/_section-break.scss +1 -1
  107. data/node_modules/govuk-frontend/govuk/helpers/_colour.scss +2 -2
  108. data/node_modules/govuk-frontend/govuk/helpers/_links.scss +6 -6
  109. data/node_modules/govuk-frontend/govuk/i18n.js +390 -0
  110. data/node_modules/govuk-frontend/govuk/macros/i18n.njk +15 -0
  111. data/node_modules/govuk-frontend/govuk/settings/_all.scss +1 -0
  112. data/node_modules/govuk-frontend/govuk/settings/_colours-palette.scss +12 -0
  113. data/node_modules/govuk-frontend/govuk/settings/_compatibility.scss +26 -0
  114. data/node_modules/govuk-frontend/govuk/settings/_typography-font.scss +23 -0
  115. data/node_modules/govuk-frontend/govuk/settings/_typography-responsive.scss +12 -0
  116. data/node_modules/govuk-frontend/govuk/settings/_warnings.scss +53 -0
  117. data/node_modules/govuk-frontend/govuk/tools/_compatibility.scss +20 -6
  118. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Date/now.js +21 -0
  119. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/dataset.js +300 -0
  120. data/node_modules/govuk-frontend/govuk/vendor/polyfills/String/prototype/trim.js +21 -0
  121. data/node_modules/govuk-frontend/govuk-esm/all.mjs +50 -27
  122. data/node_modules/govuk-frontend/govuk-esm/common/closest-attribute-value.mjs +15 -0
  123. data/node_modules/govuk-frontend/govuk-esm/common/index.mjs +159 -0
  124. data/node_modules/govuk-frontend/govuk-esm/common/normalise-dataset.mjs +58 -0
  125. data/node_modules/govuk-frontend/govuk-esm/common.mjs +6 -28
  126. data/node_modules/govuk-frontend/govuk-esm/components/accordion/accordion.mjs +113 -43
  127. data/node_modules/govuk-frontend/govuk-esm/components/button/button.mjs +67 -30
  128. data/node_modules/govuk-frontend/govuk-esm/components/character-count/character-count.mjs +325 -123
  129. data/node_modules/govuk-frontend/govuk-esm/components/checkboxes/checkboxes.mjs +9 -3
  130. data/node_modules/govuk-frontend/govuk-esm/components/details/details.mjs +22 -8
  131. data/node_modules/govuk-frontend/govuk-esm/components/error-summary/error-summary.mjs +48 -6
  132. data/node_modules/govuk-frontend/govuk-esm/components/header/header.mjs +6 -0
  133. data/node_modules/govuk-frontend/govuk-esm/components/notification-banner/notification-banner.mjs +32 -2
  134. data/node_modules/govuk-frontend/govuk-esm/components/radios/radios.mjs +9 -3
  135. data/node_modules/govuk-frontend/govuk-esm/components/skip-link/skip-link.mjs +10 -4
  136. data/node_modules/govuk-frontend/govuk-esm/components/tabs/tabs.mjs +8 -2
  137. data/node_modules/govuk-frontend/govuk-esm/i18n.mjs +380 -0
  138. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Date/now.mjs +13 -0
  139. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/dataset.mjs +68 -0
  140. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/String/prototype/trim.mjs +13 -0
  141. data/node_modules/govuk-frontend/govuk-prototype-kit/init.js +7 -0
  142. data/node_modules/govuk-frontend/govuk-prototype-kit/init.scss +12 -0
  143. data/node_modules/govuk-frontend/govuk-prototype-kit.config.json +138 -7
  144. data/node_modules/govuk-frontend/package.json +1 -1
  145. metadata +22 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c43bb9be56d4b486f1307f54c8afde28338f6e2e5e1da7cb0fcc3de5135d501e
4
- data.tar.gz: 00cec842aa8b242b7eb85aaa9c7d92e6160e08ea2b1ebe4aec988c04b6cd0c7e
3
+ metadata.gz: 4e788fa8e962e9665a5c978857dd72563e92394a2b437020e143242e48eac153
4
+ data.tar.gz: 47ebd5cd998e31cf0899e6a4dfa83949466fa1f9e357edecfb5551ca6c4b7ee3
5
5
  SHA512:
6
- metadata.gz: eaf661b0cf8beb915a3785cd80bbf9eba5e86c8de5a8bc5687baab61e69a3e1dff0018bab7036ee50ed4b98b8a0365e8d93654d121a803b5ed9289172eedfa7d
7
- data.tar.gz: 01ab80117be5494596b4d0050c560050d167772cb887a79b3af86440dc7071a2aa9c87229279ba932a89e5bd9bb0d56cf4d70d5028486114d1435dacfb99b288
6
+ metadata.gz: 55773e69567c5797c93ce788fb226f8d8ca9dcc256b12b5c6dd6caca421c5419d20f98dda3db8a8dc3baa5606915b5a0975ee738ceea752cb174feec9ce2bc5e
7
+ data.tar.gz: '093545166981ef4a4c15dd7864bfe6a3017df0a7c5a61bad7c925e1834fcfaec3e2acc9be675ae184f63213882902e20b2190bc0393ab22327b5a6f16d344593'
@@ -24,7 +24,6 @@
24
24
  })
25
25
 
26
26
  var axeOptions = {
27
- include: [selector],
28
27
  rules: axeRules
29
28
  }
30
29
 
@@ -1,3 +1,4 @@
1
+ //= require ../vendor/polyfills/closest.js
1
2
  window.GOVUK = window.GOVUK || {}
2
3
  window.GOVUK.analyticsGa4 = window.GOVUK.analyticsGa4 || {};
3
4
 
@@ -47,6 +48,180 @@ window.GOVUK.analyticsGa4 = window.GOVUK.analyticsGa4 || {};
47
48
 
48
49
  getGemVersion: function () {
49
50
  return window.GOVUK.analyticsGa4.vars.gem_version || 'not found'
51
+ },
52
+
53
+ trackFunctions: {
54
+ findTrackingAttributes: function (clicked, trackingTrigger) {
55
+ if (clicked.hasAttribute('[' + trackingTrigger + ']')) {
56
+ return clicked
57
+ } else {
58
+ return clicked.closest('[' + trackingTrigger + ']')
59
+ }
60
+ },
61
+
62
+ // create an object to split up long URLs and get around the 100 character limit on GTM data
63
+ // this gets reassembled in GA4
64
+ populateLinkPathParts: function (href) {
65
+ var path = ''
66
+ if (this.hrefIsRelative(href) || this.isMailToLink(href)) {
67
+ path = href
68
+ } else {
69
+ // This regex matches a protocol and domain name at the start of a string such as https://www.gov.uk, http://gov.uk, //gov.uk
70
+ path = href.replace(/^(http:||https:)?(\/\/)([^\/]*)/, '') // eslint-disable-line no-useless-escape
71
+ }
72
+
73
+ if (path === '/' || path.length === 0) {
74
+ return
75
+ }
76
+
77
+ /*
78
+ This will create an object with 5 keys that are indexes ("1", "2", etc.)
79
+ The values will be each part of the link path split every 100 characters, or undefined.
80
+ For example: {"1": "/hello/world/etc...", "2": "/more/path/text...", "3": undefined, "4": undefined, "5": undefined}
81
+ Undefined values are needed to override the persistent object in GTM so that any values from old pushes are overwritten.
82
+ */
83
+ var parts = path.match(/.{1,100}/g)
84
+ var obj = {}
85
+ for (var i = 0; i < 5; i++) {
86
+ obj[(i + 1).toString()] = parts[i]
87
+ }
88
+ return obj
89
+ },
90
+
91
+ hrefIsRelative: function (href) {
92
+ // Checks that a link is relative, but is not a protocol relative url
93
+ return href[0] === '/' && href[1] !== '/'
94
+ },
95
+
96
+ hrefIsAnchor: function (href) {
97
+ return href[0] === '#'
98
+ },
99
+
100
+ isMailToLink: function (href) {
101
+ return href.substring(0, 7) === 'mailto:'
102
+ },
103
+
104
+ getClickType: function (event) {
105
+ switch (event.type) {
106
+ case 'click':
107
+ if (event.ctrlKey) {
108
+ return 'ctrl click'
109
+ } else if (event.metaKey) {
110
+ return 'command/win click'
111
+ } else if (event.shiftKey) {
112
+ return 'shift click'
113
+ } else {
114
+ return 'primary click'
115
+ }
116
+ case 'mousedown':
117
+ return 'middle click'
118
+ case 'contextmenu':
119
+ return 'secondary click'
120
+ }
121
+ },
122
+
123
+ isInternalLink: function (href) {
124
+ var internalDomains = window.GOVUK.analyticsGa4.vars.internalDomains
125
+ if (this.hrefIsRelative(href) || this.hrefIsAnchor(href)) {
126
+ return true
127
+ }
128
+ var result = false
129
+ for (var i = 0; i < internalDomains.length; i++) {
130
+ var internalDomain = internalDomains[i]
131
+ if (this.hrefPointsToDomain(href, internalDomain)) {
132
+ result = true
133
+ }
134
+ }
135
+ return result
136
+ },
137
+
138
+ isExternalLink: function (href) {
139
+ return !this.isInternalLink(href)
140
+ },
141
+
142
+ hrefPointsToDomain: function (href, domain) {
143
+ /* Add a trailing slash to prevent an edge case such
144
+ as the href www.gov.uk.domain.co.uk being detected as an internal link,
145
+ if we were checking for 'www.gov.uk' instead of 'www.gov.uk/' */
146
+ if (domain.substring(domain.length) !== '/') {
147
+ domain = domain + '/'
148
+ }
149
+
150
+ /* If the href doesn't end in a slash, we add one.
151
+ This fixes an edge case where the <a href> is exactly `https://www.gov.uk`
152
+ but these checks would only look for `https://www.gov.uk/` */
153
+ if (href.substring(href.length) !== '/') {
154
+ href = href + '/'
155
+ }
156
+ // matches the domain preceded by https:// http:// or //
157
+ var regex = new RegExp('^((http)*(s)*(:)*//)(' + domain + ')', 'g')
158
+ return regex.test(href)
159
+ },
160
+
161
+ removeLinesAndExtraSpaces: function (text) {
162
+ text = text.trim()
163
+ text = text.replace(/(\r\n|\n|\r)/gm, ' ') // Replace line breaks with 1 space
164
+ text = text.replace(/\s+/g, ' ') // Replace instances of 2+ spaces with 1 space
165
+ return text
166
+ },
167
+
168
+ removeCrossDomainParams: function (href) {
169
+ if (href.indexOf('_ga') !== -1 || href.indexOf('_gl') !== -1) {
170
+ // _ga & _gl are values needed for cross domain tracking, but we don't want them included in our click tracking.
171
+ href = href.replaceAll(/_g[al]=([^&]*)/g, '')
172
+
173
+ // The following code cleans up inconsistencies such as gov.uk/&&, gov.uk/?&hello=world, gov.uk/?, and gov.uk/&.
174
+ href = href.replaceAll(/(&&)+/g, '&')
175
+ href = href.replace('?&', '?')
176
+ if (this.stringEndsWith(href, '?') || this.stringEndsWith(href, '&')) {
177
+ href = href.substring(0, href.length - 1)
178
+ }
179
+ }
180
+ return href
181
+ },
182
+
183
+ stringStartsWith: function (string, stringToFind) {
184
+ return string.substring(0, stringToFind.length) === stringToFind
185
+ },
186
+
187
+ stringEndsWith: function (string, stringToFind) {
188
+ return string.substring(string.length - stringToFind.length, string.length) === stringToFind
189
+ },
190
+
191
+ populateLinkDomain: function (href) {
192
+ // We always want mailto links to have an undefined link_domain
193
+ if (this.isMailToLink(href)) {
194
+ return undefined
195
+ }
196
+
197
+ if (this.hrefIsRelative(href) || this.hrefIsAnchor(href)) {
198
+ return this.getProtocol() + '//' + this.getHostname()
199
+ } else {
200
+ // This regex matches a protocol and domain name at the start of a string such as https://www.gov.uk, http://gov.uk, //gov.uk
201
+ var domainRegex = /^(http:||https:)?(\/\/)([^\/]*)/ // eslint-disable-line no-useless-escape
202
+ var domain = domainRegex.exec(href)[0]
203
+ return domain
204
+ }
205
+ },
206
+
207
+ getProtocol: function () {
208
+ return window.location.protocol
209
+ },
210
+
211
+ getHostname: function () {
212
+ return window.location.hostname
213
+ },
214
+
215
+ appendDomainsWithoutWWW: function (domainsArrays) {
216
+ // Add domains with www. removed, in case site hrefs are marked up without www. included.
217
+ for (var i = 0; i < domainsArrays.length; i++) {
218
+ var domain = domainsArrays[i]
219
+ if (this.stringStartsWith(domain, 'www.')) {
220
+ var domainWithoutWww = domain.replace('www.', '')
221
+ domainsArrays.push(domainWithoutWww)
222
+ }
223
+ }
224
+ }
50
225
  }
51
226
  }
52
227
 
@@ -50,7 +50,7 @@
50
50
  var schema = this.populateEcommerceSchema(searchResultsBlock, false, null)
51
51
 
52
52
  this.clearPreviousEcommerceObject()
53
- window.dataLayer.push(schema)
53
+ GOVUK.analyticsGa4.core.sendData(schema)
54
54
  },
55
55
 
56
56
  handleClick: function (event) {
@@ -62,7 +62,7 @@
62
62
  var schema = this.populateEcommerceSchema(searchResultsBlock, true, searchResult)
63
63
 
64
64
  this.clearPreviousEcommerceObject()
65
- window.dataLayer.push(schema)
65
+ GOVUK.analyticsGa4.core.sendData(schema)
66
66
  }
67
67
  },
68
68
 
@@ -97,7 +97,7 @@
97
97
  })
98
98
 
99
99
  ecommerceObject.event_data = {
100
- external: GOVUK.analyticsGa4.analyticsModules.Ga4LinkTracker.isExternalLink(searchResult.getAttribute('data-ecommerce-path')) ? 'true' : 'false'
100
+ external: GOVUK.analyticsGa4.core.trackFunctions.isExternalLink(searchResult.getAttribute('data-ecommerce-path')) ? 'true' : 'false'
101
101
  }
102
102
  } else {
103
103
  for (var i = 0; i < ecommerceRows.length; i++) {
@@ -127,7 +127,7 @@
127
127
  },
128
128
 
129
129
  clearPreviousEcommerceObject: function () {
130
- window.dataLayer.push({ search_results: { ecommerce: null } })
130
+ GOVUK.analyticsGa4.core.sendData({ search_results: { ecommerce: null } })
131
131
  },
132
132
 
133
133
  getResultsCount: function (searchResultsBlock) {
@@ -1,4 +1,4 @@
1
- // = require govuk/vendor/polyfills/Element/prototype/closest.js
1
+ //= require ../vendor/polyfills/closest.js
2
2
  window.GOVUK = window.GOVUK || {}
3
3
  window.GOVUK.Modules = window.GOVUK.Modules || {};
4
4
 
@@ -7,7 +7,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
7
7
 
8
8
  function Ga4EventTracker (module) {
9
9
  this.module = module
10
- this.trackingTrigger = 'data-ga4' // elements with this attribute get tracked
10
+ this.trackingTrigger = 'data-ga4-event' // elements with this attribute get tracked
11
11
  }
12
12
 
13
13
  Ga4EventTracker.prototype.init = function () {
@@ -29,7 +29,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
29
29
  }
30
30
 
31
31
  Ga4EventTracker.prototype.trackClick = function (event) {
32
- var target = this.findTrackingAttributes(event.target)
32
+ var target = window.GOVUK.analyticsGa4.core.trackFunctions.findTrackingAttributes(event.target, this.trackingTrigger)
33
33
  if (target) {
34
34
  var schema = new window.GOVUK.analyticsGa4.Schemas().eventSchema()
35
35
 
@@ -51,8 +51,8 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
51
51
  }
52
52
  }
53
53
 
54
- /* Ensure it only tracks aria-expanded in an accordion or element with data-ga4-expandable on it. */
55
- if (target.closest('.gem-c-accordion') || target.closest('[data-ga4-expandable]')) {
54
+ /* Ensure it only tracks aria-expanded in an element with data-ga4-expandable on it. */
55
+ if (target.closest('[data-ga4-expandable]')) {
56
56
  var ariaExpanded = this.getClosestAttribute(target, 'aria-expanded')
57
57
  }
58
58
 
@@ -88,14 +88,6 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
88
88
  }
89
89
  }
90
90
 
91
- Ga4EventTracker.prototype.findTrackingAttributes = function (clicked) {
92
- if (clicked.hasAttribute('[' + this.trackingTrigger + ']')) {
93
- return clicked
94
- } else {
95
- return clicked.closest('[' + this.trackingTrigger + ']')
96
- }
97
- }
98
-
99
91
  // check if an attribute exists or contains the attribute
100
92
  Ga4EventTracker.prototype.getClosestAttribute = function (clicked, attribute) {
101
93
  var isAttributeOnElement = clicked.getAttribute(attribute)