Skip to content

Commit c2e2081

Browse files
committed
refactor: setting the aria-current on the links
instead of the list items
1 parent 997d34c commit c2e2081

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

source/_patterns/02-components/language-switcher/language-switcher.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<li>
33
{{> elements-link href='#' hreflang='en' value='EN' title='English language' rel='alternate' }}
44
</li>
5-
<li aria-current="page">
6-
{{> elements-link href='#' hreflang='de' value='DE' title='Deutsche Sprache' rel='bookmark' }}
5+
<li>
6+
{{> elements-link href='#' hreflang='de' value='DE' title='Deutsche Sprache' rel='bookmark' current="page" }}
77
</li>
88
<li>
99
{{> elements-link href='#' hreflang='fr' value='FR' title='Langue française' rel='alternate' }}

source/_patterns/02-components/language-switcher/language-switcher.scss

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
&:hover,
1111
&:focus {
1212
li {
13-
&:not([aria-current]) {
13+
&:not(:has([aria-current="page"])) {
1414
visibility: visible;
1515
}
1616

@@ -33,19 +33,20 @@
3333
z-index: $z-index-rea-header-cmp-language-switcher-li; // * TODO: possibly rework variable naming
3434

3535
// TODO: This is an enhancement for more languages, but obviously doesn't scale that nicely and would need some rework
36-
&:not([aria-current="page"]) ~ li:not([aria-current="page"]) {
36+
&:not(:has([aria-current="page"]))
37+
~ li:not(:has([aria-current="page"])) {
3738
top: to-rem($pxValue: 54 * 2);
3839

39-
& ~ li:not([aria-current="page"]) {
40+
& ~ li:not(:has([aria-current="page"])) {
4041
top: to-rem($pxValue: 54 * 3);
4142

42-
& ~ li:not([aria-current="page"]) {
43+
& ~ li:not(:has([aria-current="page"])) {
4344
top: to-rem($pxValue: 54 * 4);
4445

45-
& ~ li:not([aria-current="page"]) {
46+
& ~ li:not(:has([aria-current="page"])) {
4647
top: to-rem($pxValue: 54 * 5);
4748

48-
& ~ li:not([aria-current="page"]) {
49+
& ~ li:not(:has([aria-current="page"])) {
4950
top: to-rem($pxValue: 54 * 6);
5051
}
5152
}
@@ -62,7 +63,7 @@
6263
text-decoration: none;
6364
}
6465

65-
&:not([aria-current]) {
66+
&:not(:has([aria-current="page"])) {
6667
visibility: hidden;
6768

6869
.elm-link {
@@ -77,7 +78,7 @@
7778
}
7879
}
7980

80-
&[aria-current] {
81+
&:has([aria-current]) {
8182
position: initial;
8283

8384
.elm-link {

0 commit comments

Comments
 (0)