Skip to content

Commit 6c84a41

Browse files
committed
fix(pat navigation): Do not break when no item wrapper is found.
1 parent b2ecbbe commit 6c84a41

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/pat/navigation/navigation.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,11 @@ export default Base.extend({
168168
new URL(nav_item.getAttribute("href", ""), current_url)?.href
169169
);
170170

171-
const wrapper = this.options.itemWrapper
172-
? nav_item.closest(this.options.itemWrapper)
173-
: nav_item.parentNode;
171+
const wrapper = nav_item.closest(this.options.itemWrapper);
174172

175173
if (nav_url === current_url_prepared) {
176174
nav_item.classList.add(this.options.currentClass);
177-
wrapper.classList.add(this.options.currentClass);
175+
wrapper?.classList.add(this.options.currentClass);
178176
this.mark_in_path(nav_item);
179177
} else if (
180178
// Compare the current navigation item url with a slash at the
@@ -185,7 +183,7 @@ export default Base.extend({
185183
nav_url !== portal_url
186184
) {
187185
nav_item.classList.add(this.options.inPathClass);
188-
wrapper.classList.add(this.options.inPathClass);
186+
wrapper?.classList.add(this.options.inPathClass);
189187
} else {
190188
// Not even in path.
191189
continue;

0 commit comments

Comments
 (0)