Skip to content

Commit e9da003

Browse files
committed
feat(pat navigation): When a navigation wrapper is in-path, also mark the corresponding anchor as in-path.
1 parent 458e76b commit e9da003

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/pat/navigation/navigation.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ export default Base.extend({
114114
while (path_el) {
115115
if (!path_el.matches(`.${this.options.currentClass}`)) {
116116
path_el.classList.add(this.options.inPathClass);
117+
for (const it of [...path_el.children].filter((it) => it.matches("a"))) {
118+
it.classList.add(this.options.inPathClass);
119+
}
117120
log.debug("Marked item as in-path", path_el);
118121
}
119122
path_el = this.get_parent(path_el, this.options.itemWrapper, this.el);

src/pat/navigation/navigation.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ describe("Navigation pattern tests", function () {
8888
expect(w1.classList.contains("current")).toBeFalsy();
8989
expect(w1.classList.contains("navigation-in-path")).toBeTruthy();
9090
expect(a1.classList.contains("current")).toBeFalsy();
91-
expect(a1.classList.contains("navigation-in-path")).toBeFalsy();
91+
expect(a1.classList.contains("navigation-in-path")).toBeTruthy();
9292
expect(w11.classList.contains("current")).toBeTruthy();
9393
expect(w11.classList.contains("navigation-in-path")).toBeFalsy();
9494
expect(a11.classList.contains("current")).toBeTruthy();
@@ -118,7 +118,7 @@ describe("Navigation pattern tests", function () {
118118
expect(w2.classList.contains("active")).toBeFalsy();
119119
expect(w2.classList.contains("in-path")).toBeTruthy();
120120
expect(a2.classList.contains("active")).toBeFalsy();
121-
expect(a2.classList.contains("in-path")).toBeFalsy();
121+
expect(a2.classList.contains("in-path")).toBeTruthy();
122122
expect(w21.classList.contains("active")).toBeTruthy();
123123
expect(w21.classList.contains("in-path")).toBeFalsy();
124124
expect(a21.classList.contains("active")).toBeTruthy();
@@ -144,7 +144,7 @@ describe("Navigation pattern tests", function () {
144144
expect(w2.classList.contains("active")).toBeFalsy();
145145
expect(w2.classList.contains("in-path")).toBeTruthy();
146146
expect(a2.classList.contains("active")).toBeFalsy();
147-
expect(a2.classList.contains("in-path")).toBeFalsy();
147+
expect(a2.classList.contains("in-path")).toBeTruthy();
148148
expect(w21.classList.contains("active")).toBeTruthy();
149149
expect(w21.classList.contains("in-path")).toBeFalsy();
150150
expect(a21.classList.contains("active")).toBeTruthy();
@@ -193,7 +193,7 @@ describe("Navigation pattern tests - no predefined structure", function () {
193193
expect(w1.classList.contains("current")).toBeFalsy();
194194
expect(w1.classList.contains("navigation-in-path")).toBeTruthy();
195195
expect(a1.classList.contains("current")).toBeFalsy();
196-
expect(a1.classList.contains("navigation-in-path")).toBeFalsy();
196+
expect(a1.classList.contains("navigation-in-path")).toBeTruthy();
197197
expect(w11.classList.contains("current")).toBeTruthy();
198198
expect(w11.classList.contains("navigation-in-path")).toBeFalsy();
199199
expect(a11.classList.contains("current")).toBeTruthy();

0 commit comments

Comments
 (0)