desy-html 13.0.2 → 14.0.0

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.
@@ -0,0 +1,508 @@
1
+ 'use strict';
2
+ export function TreeGrid(treegridElem, doAllowRowFocus, doStartRowFocus) {
3
+ function initAttributes() {
4
+ // Make sure focusable elements are not in the tab order
5
+ // They will be added back in for the active row
6
+ setTabIndexOfFocusableElements(treegridElem, -1);
7
+
8
+ // Add tabindex="0" to first row, "-1" to other rows
9
+ // We will use the roving tabindex method since aria-activedescendant
10
+ var rows = getAllRows();
11
+ var index = rows.length;
12
+ var startRowIndex = doStartRowFocus ? 0 : -1;
13
+
14
+ while (index--) {
15
+ if (doAllowRowFocus) {
16
+ rows[index].tabIndex = index === startRowIndex ? 0 : -1;
17
+ } else {
18
+ setTabIndexForCellsInRow(rows[index], -1);
19
+ moveAriaExpandedToFirstCell(rows[index]);
20
+ }
21
+ }
22
+ // Here we collapse all items if parent not expanded (hidden class)
23
+ rows.forEach(r => {
24
+ if (isExpandable(r)) {
25
+ changeExpanded(isExpanded(r), r);
26
+ }
27
+ });
28
+
29
+ if (doStartRowFocus) {
30
+ return;
31
+ }
32
+
33
+ // Start with cell focus
34
+ var firstCell = getNavigableCols(rows[0])[0];
35
+ setTabIndexForCell(firstCell);
36
+ }
37
+
38
+ function setTabIndexForCell(cell, tabIndex) {
39
+ var focusable = getFocusableElements(cell)[0] || cell;
40
+ focusable.tabIndex = tabIndex;
41
+ }
42
+
43
+ function setTabIndexForCellsInRow(row, tabIndex) {
44
+ var cells = getNavigableCols(row);
45
+ var cellIndex = cells.length;
46
+ while (cellIndex--) {
47
+ setTabIndexForCell(cells[cellIndex], tabIndex);
48
+ }
49
+ }
50
+
51
+ function getAllRows() {
52
+ var nodeList = treegridElem.querySelectorAll('tbody > tr');
53
+ return Array.prototype.slice.call(nodeList);
54
+ }
55
+
56
+ function getFocusableElements(root) {
57
+ // textarea not supported as a cell widget as it's multiple lines
58
+ // and needs up/down keys
59
+ // These should all be descendants of a cell
60
+ var nodeList = root.querySelectorAll('a,button,input,td>[tabindex],th>[tabindex]');
61
+ return Array.prototype.slice.call(nodeList);
62
+ }
63
+
64
+ function setTabIndexOfFocusableElements(root, tabIndex) {
65
+ var focusableElements = getFocusableElements(root);
66
+ var index = focusableElements.length;
67
+ while (index--) {
68
+ focusableElements[index].tabIndex = tabIndex;
69
+ }
70
+ }
71
+
72
+ function getAllNavigableRows() {
73
+ var nodeList = treegridElem.querySelectorAll(
74
+ 'tbody > tr:not([class~="hidden"])'
75
+ );
76
+ // Convert to array so that we can use array methods on it
77
+ return Array.prototype.slice.call(nodeList);
78
+ }
79
+
80
+ function getNavigableCols(currentRow) {
81
+ return Array.from(currentRow.querySelectorAll('td, th'));
82
+ }
83
+
84
+ function restrictIndex(index, numItems) {
85
+ if (index < 0) {
86
+ return 0;
87
+ }
88
+ return index >= numItems ? index - 1 : index;
89
+ }
90
+
91
+ function focus(elem) {
92
+ elem.tabIndex = 0; // Ensure focusable
93
+ elem.focus();
94
+ }
95
+
96
+ function focusCell(cell) {
97
+ // Check for focusable child such as link or textbox
98
+ // and use that if available
99
+ var focusableChildren = getFocusableElements(cell);
100
+ focus(focusableChildren[0] || cell);
101
+ }
102
+
103
+ // Restore tabIndex to what it should be when focus switches from
104
+ // one treegrid item to another
105
+ function onFocusIn(event) {
106
+ var newTreeGridFocus =
107
+ event.target !== window &&
108
+ treegridElem.contains(event.target) &&
109
+ event.target;
110
+
111
+ // The last row we considered focused
112
+ var oldCurrentRow = enableTabbingInActiveRowDescendants.tabbingRow;
113
+ if (oldCurrentRow) {
114
+ enableTabbingInActiveRowDescendants(false, oldCurrentRow);
115
+ }
116
+ if (
117
+ doAllowRowFocus &&
118
+ onFocusIn.prevTreeGridFocus &&
119
+ (onFocusIn.prevTreeGridFocus.localName === 'td' || onFocusIn.prevTreeGridFocus.localName === 'th')
120
+ ) {
121
+ // Was focused on td, remove tabIndex so that it's not focused on click
122
+ onFocusIn.prevTreeGridFocus.removeAttribute('tabindex');
123
+ }
124
+
125
+ if (newTreeGridFocus) {
126
+ // Stayed in treegrid
127
+ if (oldCurrentRow) {
128
+ // There will be a different current row that will be
129
+ // the tabbable one
130
+ oldCurrentRow.tabIndex = -1;
131
+ }
132
+
133
+ // The new row
134
+ var currentRow = getRowWithFocus();
135
+ if (currentRow) {
136
+ currentRow.tabIndex = 0;
137
+ // Items within current row are also tabbable
138
+ enableTabbingInActiveRowDescendants(true, currentRow);
139
+ }
140
+ }
141
+
142
+ onFocusIn.prevTreeGridFocus = newTreeGridFocus;
143
+ }
144
+
145
+ // Set whether interactive elements within a row are tabbable
146
+ function enableTabbingInActiveRowDescendants(isTabbingOn, row) {
147
+ if (row) {
148
+ setTabIndexOfFocusableElements(row, isTabbingOn ? 0 : -1);
149
+ if (isTabbingOn) {
150
+ enableTabbingInActiveRowDescendants.tabbingRow = row;
151
+ } else {
152
+ if (enableTabbingInActiveRowDescendants.tabbingRow === row) {
153
+ enableTabbingInActiveRowDescendants.tabbingRow = null;
154
+ }
155
+ }
156
+ }
157
+ }
158
+
159
+ // The row with focus is the row that either has focus or an element
160
+ // inside of it has focus
161
+ function getRowWithFocus() {
162
+ return getContainingRow(document.activeElement);
163
+ }
164
+
165
+ function getContainingRow(start) {
166
+ var possibleRow = start;
167
+ if (treegridElem.contains(possibleRow)) {
168
+ while (possibleRow !== treegridElem) {
169
+ if (possibleRow.localName === 'tr') {
170
+ return possibleRow;
171
+ }
172
+ possibleRow = possibleRow.parentElement;
173
+ }
174
+ }
175
+ }
176
+
177
+ function isRowFocused() {
178
+ return getRowWithFocus() === document.activeElement;
179
+ }
180
+
181
+ // Note: contenteditable not currently supported
182
+ function isEditableFocused() {
183
+ var focusedElem = document.activeElement;
184
+ return focusedElem.localName === 'input';
185
+ }
186
+
187
+ function getColWithFocus(currentRow) {
188
+ if (currentRow) {
189
+ var possibleCol = document.activeElement;
190
+ if (currentRow.contains(possibleCol)) {
191
+ while (possibleCol !== currentRow) {
192
+ if (possibleCol.localName === 'td' || possibleCol.localName === 'th') {
193
+ return possibleCol;
194
+ }
195
+ possibleCol = possibleCol.parentElement;
196
+ }
197
+ }
198
+ }
199
+ }
200
+
201
+ function getLevel(row) {
202
+ return row && parseInt(row.getAttribute('aria-level'));
203
+ }
204
+
205
+ // Move backwards (direction = -1) or forwards (direction = 1)
206
+ // If we also need to move down/up a level, requireLevelChange = true
207
+ // When
208
+ function moveByRow(direction, requireLevelChange) {
209
+ var currentRow = getRowWithFocus();
210
+ var requiredLevel =
211
+ requireLevelChange && currentRow && getLevel(currentRow) + direction;
212
+ var rows = getAllNavigableRows();
213
+ var numRows = rows.length;
214
+ var rowIndex = currentRow ? rows.indexOf(currentRow) : -1;
215
+ // When moving down a level, only allow moving to next row as the
216
+ // first child will never be farther than that
217
+ var maxDistance = requireLevelChange && direction === 1 ? 1 : NaN;
218
+
219
+ // Move in direction until required level is found
220
+ do {
221
+ if (maxDistance-- === 0) {
222
+ return; // Failed to find required level, return without focus change
223
+ }
224
+ rowIndex = restrictIndex(rowIndex + direction, numRows);
225
+ } while (requiredLevel && requiredLevel !== getLevel(rows[rowIndex]));
226
+
227
+ if (!focusSameColInDifferentRow(currentRow, rows[rowIndex])) {
228
+ focus(rows[rowIndex]);
229
+ }
230
+ }
231
+
232
+ function focusSameColInDifferentRow(fromRow, toRow) {
233
+ var currentCol = getColWithFocus(fromRow);
234
+ if (!currentCol) {
235
+ return;
236
+ }
237
+
238
+ var fromCols = getNavigableCols(fromRow);
239
+ var currentColIndex = fromCols.indexOf(currentCol);
240
+
241
+ if (currentColIndex < 0) {
242
+ return;
243
+ }
244
+
245
+ var toCols = getNavigableCols(toRow);
246
+ // Focus the first focusable element inside the <td> or <th>
247
+ focusCell(toCols[currentColIndex]);
248
+ return true;
249
+ }
250
+
251
+ function moveToExtreme(direction) {
252
+ var currentRow = getRowWithFocus();
253
+ if (!currentRow) {
254
+ return;
255
+ }
256
+ var currentCol = getColWithFocus(currentRow);
257
+ if (currentCol) {
258
+ moveToExtremeCol(direction, currentRow);
259
+ } else {
260
+ // Move to first/last row
261
+ moveToExtremeRow(direction);
262
+ }
263
+ }
264
+
265
+ function moveByCol(direction) {
266
+ var currentRow = getRowWithFocus();
267
+ if (!currentRow) {
268
+ return;
269
+ }
270
+ var cols = getNavigableCols(currentRow);
271
+ var numCols = cols.length;
272
+ var currentCol = getColWithFocus(currentRow);
273
+ var currentColIndex = cols.indexOf(currentCol);
274
+ // First right arrow moves to first column
275
+ var newColIndex =
276
+ currentCol || direction < 0 ? currentColIndex + direction : 0;
277
+ // Moving past beginning focuses row
278
+ if (doAllowRowFocus && newColIndex < 0) {
279
+ focus(currentRow);
280
+ return;
281
+ }
282
+ newColIndex = restrictIndex(newColIndex, numCols);
283
+ focusCell(cols[newColIndex]);
284
+ }
285
+
286
+ function moveToExtremeCol(direction, currentRow) {
287
+ // Move to first/last col
288
+ var cols = getNavigableCols(currentRow);
289
+ var desiredColIndex = direction < 0 ? 0 : cols.length - 1;
290
+ focusCell(cols[desiredColIndex]);
291
+ }
292
+
293
+ function moveToExtremeRow(direction) {
294
+ var rows = getAllNavigableRows();
295
+ var newRow = rows[direction > 0 ? rows.length - 1 : 0];
296
+ if (!focusSameColInDifferentRow(getRowWithFocus(), newRow)) {
297
+ focus(newRow);
298
+ }
299
+ }
300
+
301
+ function doPrimaryAction() {
302
+ var currentRow = getRowWithFocus();
303
+ if (!currentRow) {
304
+ return;
305
+ }
306
+
307
+ // If first col has focused, toggle expand/collapse
308
+ toggleExpanded(currentRow);
309
+ }
310
+
311
+ function toggleExpanded(row) {
312
+ var cols = getNavigableCols(row);
313
+ var currentCol = getColWithFocus(row);
314
+ if (currentCol === cols[0] && isExpandable(row)) {
315
+ changeExpanded(!isExpanded(row), row);
316
+ }
317
+ }
318
+
319
+ function changeExpanded(doExpand, row) {
320
+ var currentRow = row || getRowWithFocus();
321
+ if (!currentRow) {
322
+ return;
323
+ }
324
+ var currentLevel = getLevel(currentRow);
325
+ var rows = getAllRows();
326
+ var currentRowIndex = rows.indexOf(currentRow);
327
+ var didChange;
328
+ var doExpandLevel = [];
329
+ doExpandLevel[currentLevel + 1] = doExpand;
330
+
331
+ while (++currentRowIndex < rows.length) {
332
+ var nextRow = rows[currentRowIndex];
333
+ var rowLevel = getLevel(nextRow);
334
+ if (rowLevel <= currentLevel) {
335
+ break; // Next row is not a level down from current row
336
+ }
337
+ // Only expand the next level if this level is expanded
338
+ // and previous level is expanded
339
+ doExpandLevel[rowLevel + 1] =
340
+ doExpandLevel[rowLevel] && isExpanded(nextRow);
341
+ var willHideRow = !doExpandLevel[rowLevel];
342
+ var isRowHidden = nextRow.classList.contains('hidden');
343
+
344
+ if (willHideRow !== isRowHidden) {
345
+ if (willHideRow) {
346
+ nextRow.classList.add('hidden');
347
+ } else {
348
+ nextRow.classList.remove('hidden');
349
+ }
350
+ didChange = true;
351
+ }
352
+ }
353
+ if (didChange) {
354
+ setAriaExpanded(currentRow, doExpand);
355
+ return true;
356
+ }
357
+ }
358
+
359
+ // Mirror aria-expanded from the row to the first cell in that row
360
+ // (TBD is this a good idea? How else will screen reader user hear
361
+ // that the cell represents the opportunity to collapse/expand rows?)
362
+ function moveAriaExpandedToFirstCell(row) {
363
+ var expandedValue = row.getAttribute('aria-expanded');
364
+ var firstCell = getNavigableCols(row)[0];
365
+ if (expandedValue) {
366
+ firstCell.setAttribute('aria-expanded', expandedValue);
367
+ row.removeAttribute('aria-expanded');
368
+ }
369
+ }
370
+
371
+ function getAriaExpandedElem(row) {
372
+ return doAllowRowFocus ? row : getNavigableCols(row)[0];
373
+ }
374
+
375
+ function setAriaExpanded(row, doExpand) {
376
+ var elem = getAriaExpandedElem(row);
377
+ elem.setAttribute('aria-expanded', doExpand);
378
+ }
379
+
380
+ function isExpandable(row) {
381
+ var elem = getAriaExpandedElem(row);
382
+ return elem.hasAttribute('aria-expanded');
383
+ }
384
+
385
+ function isExpanded(row) {
386
+ var elem = getAriaExpandedElem(row);
387
+ return elem.getAttribute('aria-expanded') === 'true';
388
+ }
389
+
390
+ function onKeyDown(event) {
391
+ var ENTER = 13;
392
+ var UP = 38;
393
+ var DOWN = 40;
394
+ var LEFT = 37;
395
+ var RIGHT = 39;
396
+ var HOME = 36;
397
+ var END = 35;
398
+ var CTRL_HOME = -HOME;
399
+ var CTRL_END = -END;
400
+
401
+ var numModifiersPressed =
402
+ event.ctrlKey + event.altKey + event.shiftKey + event.metaKey;
403
+
404
+ var key = event.keyCode;
405
+
406
+ if (numModifiersPressed === 1 && event.ctrlKey) {
407
+ key = -key; // Treat as negative key value when ctrl pressed
408
+ } else if (numModifiersPressed) {
409
+ return;
410
+ }
411
+
412
+ switch (key) {
413
+ case DOWN:
414
+ moveByRow(1);
415
+ break;
416
+ case UP:
417
+ moveByRow(-1);
418
+ break;
419
+ case LEFT:
420
+ if (isEditableFocused()) {
421
+ return; // Leave key for editable area
422
+ }
423
+ if (isRowFocused()) {
424
+ changeExpanded(false) || moveByRow(-1, true);
425
+ } else {
426
+ moveByCol(-1);
427
+ }
428
+ break;
429
+ case RIGHT:
430
+ if (isEditableFocused()) {
431
+ return; // Leave key for editable area
432
+ }
433
+
434
+ // If row: try to expand
435
+ // If col or can't expand, move column to right
436
+ if (!isRowFocused() || !changeExpanded(true)) {
437
+ moveByCol(1);
438
+ }
439
+ break;
440
+ case CTRL_HOME:
441
+ moveToExtremeRow(-1);
442
+ break;
443
+ case HOME:
444
+ if (isEditableFocused()) {
445
+ return; // Leave key for editable area
446
+ }
447
+ moveToExtreme(-1);
448
+ break;
449
+ case CTRL_END:
450
+ moveToExtremeRow(1);
451
+ break;
452
+ case END:
453
+ if (isEditableFocused()) {
454
+ return; // Leave key for editable area
455
+ }
456
+ moveToExtreme(1);
457
+ break;
458
+ case ENTER:
459
+ doPrimaryAction();
460
+ break;
461
+ default:
462
+ return;
463
+ }
464
+
465
+ if (key === ENTER && (
466
+ (document.activeElement.tagName.toLowerCase() === 'a' && document.activeElement.hasAttribute('href')) ||
467
+ document.activeElement.tagName.toLowerCase() === 'button'
468
+ )) {
469
+ return;
470
+ }
471
+ // Important: don't use key for anything else, such as scrolling
472
+ event.preventDefault();
473
+ }
474
+
475
+ function onClick(iconElem) {
476
+ const row = iconElem.closest('tr');
477
+ if (!row) return;
478
+ if (!isExpandable(row)) return;
479
+
480
+ changeExpanded(!isExpanded(row), row);
481
+ }
482
+ // Double click on row toggles expansion
483
+ function onDoubleClick(event) {
484
+ var row = getContainingRow(event.target);
485
+ if (row) {
486
+ if (isExpandable(row)) {
487
+ changeExpanded(!isExpanded(row), row);
488
+ }
489
+ event.preventDefault();
490
+ }
491
+ }
492
+
493
+ initAttributes();
494
+ treegridElem.addEventListener('keydown', onKeyDown);
495
+ treegridElem.querySelectorAll('.c-treegrid__icon').forEach(icon => icon.addEventListener('click', () => onClick(icon)));
496
+ treegridElem.addEventListener('dblclick', e => {
497
+ if (!e.target.closest('.c-treegrid__icon')) {
498
+ onDoubleClick(e);
499
+ }
500
+ });
501
+
502
+ // Polyfill for focusin necessary for Firefox < 52
503
+ window.addEventListener(
504
+ window.onfocusin ? 'focusin' : 'focus',
505
+ onFocusIn,
506
+ true
507
+ );
508
+ }
@@ -33,7 +33,7 @@ export function Treeitem(aria) {
33
33
  this.domNode = node;
34
34
  this.label = node.textContent.trim();
35
35
 
36
- if(this.domNode.getAttribute("aria-current")) {
36
+ if (this.domNode.getAttribute("aria-current")) {
37
37
  var getLabel = this.domNode.querySelector('label')
38
38
  getLabel.setAttribute("aria-current", "page")
39
39
  }
@@ -79,14 +79,20 @@ export function Treeitem(aria) {
79
79
 
80
80
  aria.Treeitem.prototype.init = function () {
81
81
  this.domNode.tabIndex = -1;
82
+ this.domNode.setAttribute('aria-checked', false);
82
83
 
83
84
  if (!this.domNode.getAttribute('role')) {
84
85
  this.domNode.setAttribute('role', 'treeitem');
85
86
  }
86
87
 
87
- if(!this.domNode.getAttribute('disabled')){
88
+ if (!this.domNode.getAttribute('disabled')) {
88
89
  this.domNode.addEventListener('keydown', this.handleKeydown.bind(this));
89
- this.domNode.addEventListener('click', this.handleClick.bind(this));
90
+ if (this.domNode.closest('ul.c-tree')?.dataset.treeNavigation === 'true') {
91
+ this.onIconClick = this.domNode.querySelector('.c-tree__icon');
92
+ this.onIconClick?.addEventListener('click', this.handleClick.bind(this));
93
+ } else {
94
+ this.domNode.addEventListener('click', this.handleClick.bind(this));
95
+ }
90
96
  this.domNode.addEventListener('focus', this.handleFocus.bind(this));
91
97
  this.domNode.addEventListener('blur', this.handleBlur.bind(this));
92
98
  }
@@ -116,18 +122,17 @@ export function Treeitem(aria) {
116
122
  /* EVENT HANDLERS */
117
123
 
118
124
  aria.Treeitem.prototype.handleKeydown = function (event) {
119
-
120
125
  const targetElement = event.currentTarget;
121
126
  let flag = false;
122
127
  let char = event.key;
123
128
  const getCurrentCheckbox = targetElement.querySelector('input');
124
129
  const getAllChildrenOfTree = targetElement.parentElement.querySelectorAll('input');
125
130
 
126
- function isPrintableCharacter (str) {
131
+ function isPrintableCharacter(str) {
127
132
  return str.length === 1 && str.match(/\S/);
128
133
  }
129
134
 
130
- function printableCharacter (item) {
135
+ function printableCharacter(item) {
131
136
  if (char == '*') {
132
137
  item.tree.expandAllSiblingItems(item);
133
138
  flag = true;
@@ -154,12 +159,13 @@ export function Treeitem(aria) {
154
159
  case this.keyCode.SPACE:
155
160
  case this.keyCode.RETURN:
156
161
  const typeOfInput = getCurrentCheckbox.type
157
- if(typeOfInput === 'radio') {
162
+ if (typeOfInput === 'radio') {
158
163
  for (let item of getAllChildrenOfTree) {
159
164
  item.checked = false
160
165
  }
161
166
  }
162
167
  getCurrentCheckbox.checked = getCurrentCheckbox.checked === true ? false : true
168
+ targetElement.setAttribute('aria-checked', getCurrentCheckbox.checked ? 'true' : 'false');
163
169
  flag = true;
164
170
  break;
165
171
 
@@ -273,10 +279,10 @@ export function Treeitem(aria) {
273
279
  };
274
280
 
275
281
  function arrayOrSingleElement(elementId, itemsIds, open) {
276
- if(typeof itemsIds === 'object' && open !== null) {
282
+ if (typeof itemsIds === 'object' && open !== null) {
277
283
  itemsIds.forEach((item) => {
278
284
  const selectItem = document.querySelector(`#${elementId} #${item}`)
279
- if(selectItem) {
285
+ if (selectItem) {
280
286
  activateElement(selectItem, open)
281
287
  } else {
282
288
  returnMessage()
@@ -284,21 +290,21 @@ export function Treeitem(aria) {
284
290
  })
285
291
  }
286
292
 
287
- if(typeof itemsIds !== 'object' && open !== null) {
293
+ if (typeof itemsIds !== 'object' && open !== null) {
288
294
  const getElement = document.querySelector(`nav #${elementId}`);
289
295
  const isTreeNavigation = getElement.hasAttribute('data-tree-navigation');
290
296
  const selectItem = document.querySelector(`#${elementId} #${itemsIds}`)
291
- if(selectItem) {
297
+ if (selectItem) {
292
298
  activateElement(selectItem, open, isTreeNavigation)
293
299
  } else {
294
300
  returnMessage()
295
301
  }
296
302
  }
297
303
 
298
- if(typeof itemsIds === 'object' && open === null) {
304
+ if (typeof itemsIds === 'object' && open === null) {
299
305
  itemsIds.forEach((item) => {
300
306
  const selectItem = document.querySelector(`#${elementId} #${item[0]}`)
301
- if(selectItem) {
307
+ if (selectItem) {
302
308
  activateElement(selectItem, item[1])
303
309
  } else {
304
310
  console.log('There is no item with this id in the document.');
@@ -309,9 +315,9 @@ export function Treeitem(aria) {
309
315
  }
310
316
 
311
317
  function activateElement(item, open, treeNav = false) {
312
- if(open === true) {
318
+ if (open === true) {
313
319
  item.setAttribute('aria-expanded', 'true');
314
- if(treeNav) {
320
+ if (treeNav) {
315
321
  const getLink = item.querySelector('a')
316
322
  getLink.setAttribute("aria-current", "page");
317
323
  getLink.innerHTML = `<strong class="font-bold">${getLink.textContent}</strong>`;
@@ -323,13 +329,13 @@ export function Treeitem(aria) {
323
329
  }
324
330
 
325
331
  function recursiveParent(item) {
326
- if(item.parentNode.tagName === "UL" && typeof item.parentNode.id === "string" && item.parentNode.id.length === 0) {
332
+ if (item.parentNode.tagName === "UL" && typeof item.parentNode.id === "string" && item.parentNode.id.length === 0) {
327
333
  recursiveParent(item.parentNode)
328
- } else if(item.parentNode.tagName === "LI" && item.parentNode.getAttribute('aria-expanded') === "true") {
334
+ } else if (item.parentNode.tagName === "LI" && item.parentNode.getAttribute('aria-expanded') === "true") {
329
335
  recursiveParent(item.parentNode)
330
- } else if(item.parentNode.getAttribute('aria-expanded') === "false") {
336
+ } else if (item.parentNode.getAttribute('aria-expanded') === "false") {
331
337
  item.parentNode.setAttribute('aria-expanded', 'true');
332
- if(item.parentNode.parentNode.parentNode.getAttribute('aria-expanded') === "false") {
338
+ if (item.parentNode.parentNode.parentNode.getAttribute('aria-expanded') === "false") {
333
339
  recursiveParent(item.parentNode)
334
340
  }
335
341
  }