Skip to content

Commit 748e9df

Browse files
fix(a11y): small fix when bychars or bywords is on
1 parent eb95589 commit 748e9df

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/index.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,12 @@ export default class SplitText {
119119
}
120120
}
121121

122-
if (!this.options.noAriaLabel) {
122+
if (!this.options.noAriaLabel && (byChars || byWords)) {
123123
this.recursiveAriaLabel(element);
124124

125125
// Handle A tags
126-
const aTags = toArray(element.getElementsByTagName('A'));
127-
aTags.forEach((aTag) => {
128-
if (!aTag.getAttribute('aria-label')) {
129-
aTag.setAttribute('aria-label', aTag.textContent);
130-
}
131-
});
126+
const focusableTags = toArray(element.querySelectorAll('a, button'));
127+
focusableTags.forEach(this.createAriaLabel);
132128
}
133129
});
134130

@@ -552,7 +548,6 @@ export default class SplitText {
552548
const line = document.createElement('span');
553549
line.style.setProperty('display', 'block');
554550
line.className = 'line';
555-
// line.setAttribute('aria-hidden', true);
556551
return parent ? parent.appendChild(line) : line;
557552
}
558553

0 commit comments

Comments
 (0)