Skip to content

Commit c55caf1

Browse files
authored
Merge pull request #209 from localgovdrupal/fix/2.x/replace-deprecated-javascript-apis
fix: replace deprecated javascript apis
2 parents 0dde9d0 + 0eacb75 commit c55caf1

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

modules/localgov_subsites_paragraphs/js/localgov-accordion.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@
247247
// Trigger create/destroy functions at different screen widths
248248
// based on the value of data-accordion-tabs-switch attribute.
249249
if (window.matchMedia) {
250-
mq.addListener(() => {
250+
mq.addEventListener("change", () => {
251251
breakpointCheck();
252252
});
253253
breakpointCheck();

modules/localgov_subsites_paragraphs/js/localgov-tabs.es6.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@
8080
tab.addEventListener('keydown', e => {
8181
let newActiveControl;
8282

83-
switch (e.which) {
84-
case 37:
83+
switch (e.key) {
84+
case 'ArrowLeft':
8585
// Left arrow. If there's a previous element, switch to it.
8686
if (i - 1 >= 0) {
8787
newActiveControl = tabList
@@ -94,7 +94,7 @@
9494
newActiveControl[0].focus();
9595
}
9696
break;
97-
case 39:
97+
case 'ArrowRight':
9898
// Right arrow. If there's a next element, switch to it.
9999
if (i + 1 < tabPanelsNumber) {
100100
newActiveControl = tabList
@@ -107,7 +107,7 @@
107107
newActiveControl[0].focus();
108108
}
109109
break;
110-
case 40:
110+
case 'ArrowDown':
111111
// Arrow down. Move focus into the active panel.
112112
tabPanels[i].focus();
113113
break;
@@ -177,7 +177,7 @@
177177
// Trigger create/destroy functions at different screen widths
178178
// based on the value of data-accordion-tabs-switch attribute.
179179
if (window.matchMedia) {
180-
mq.addListener(() => {
180+
mq.addEventListener("change", () => {
181181
breakpointCheck();
182182
});
183183
breakpointCheck();

modules/localgov_subsites_paragraphs/js/localgov-tabs.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,24 +89,24 @@
8989
tab.addEventListener('keydown', function (e) {
9090
var newActiveControl = void 0;
9191

92-
switch (e.which) {
93-
case 37:
92+
switch (e.key) {
93+
case 'ArrowLeft':
9494
// Left arrow. If there's a previous element, switch to it.
9595
if (i - 1 >= 0) {
9696
newActiveControl = tabList.querySelectorAll('li')[i - 1].querySelectorAll('button');
9797
Drupal.behaviors.localgovTabs.switchTab(newActiveControl[0], tabs);
9898
newActiveControl[0].focus();
9999
}
100100
break;
101-
case 39:
101+
case 'ArrowRight':
102102
// Right arrow. If there's a next element, switch to it.
103103
if (i + 1 < tabPanelsNumber) {
104104
newActiveControl = tabList.querySelectorAll('li')[i + 1].querySelectorAll('button');
105105
Drupal.behaviors.localgovTabs.switchTab(newActiveControl[0], tabs);
106106
newActiveControl[0].focus();
107107
}
108108
break;
109-
case 40:
109+
case 'ArrowDown':
110110
// Arrow down. Move focus into the active panel.
111111
tabPanels[i].focus();
112112
break;
@@ -179,7 +179,7 @@
179179
// Trigger create/destroy functions at different screen widths
180180
// based on the value of data-accordion-tabs-switch attribute.
181181
if (window.matchMedia) {
182-
mq.addListener(function () {
182+
mq.addEventListener("change", () => {
183183
breakpointCheck();
184184
});
185185
breakpointCheck();

0 commit comments

Comments
 (0)