Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getListItem_(target) {
let isListItem = this.adapter_.elementContainsClass(target, MDCListFoundation.cssClasses.LIST_ITEM_CLASS);
while (!isListItem) {
target = this.adapter_.getParentElement(target);
if (target) {
isListItem = this.adapter_.elementContainsClass(target, MDCListFoundation.cssClasses.LIST_ITEM_CLASS);
} else { // target has no parent element.
return null;
}
}
return target;
}
getSelectionGroup_(listItem) {
let parent = this.adapter_.getParentElement(listItem);
let isGroup = this.adapter_.elementContainsClass(parent, cssClasses.MENU_SELECTION_GROUP);
// Iterate through ancestors until we find the group or get to the list.
while (!isGroup && !this.adapter_.elementContainsClass(parent, MDCListFoundation.cssClasses.ROOT)) {
parent = this.adapter_.getParentElement(listItem);
isGroup = this.adapter_.elementContainsClass(parent, cssClasses.MENU_SELECTION_GROUP);
}
if (isGroup) {
return parent;
} else {
return null;
}
}
getListItem_(target) {
let isListItem = this.adapter_.elementContainsClass(target, MDCListFoundation.cssClasses.LIST_ITEM_CLASS);
while (!isListItem) {
target = this.adapter_.getParentElement(target);
if (target) {
isListItem = this.adapter_.elementContainsClass(target, MDCListFoundation.cssClasses.LIST_ITEM_CLASS);
} else { // target has no parent element.
return null;
}
}
return target;
}
mounted() {
this.drawer_ = this.$refs.drawer;
const listEl = this.$el.querySelector(
`.${MDCListFoundation.cssClasses.ROOT}`,
);
if (listEl) {
this.list_ = listEl;
this.list_.wrapFocus = true;
}
const adapter = {
addClass: className => this.$set(this.classes, className, true),
removeClass: className => this.$delete(this.classes, className),
hasClass: className => this.drawer_.classList.contains(className),
elementHasClass: (element, className) =>
element.classList.contains(className),
saveFocus: () => {
this.previousFocus_ = document.activeElement;
},
restoreFocus: () => {
focusActiveNavigationItem: () => {
const activeNavItemEl = this.drawer_.querySelector(
`.${MDCListFoundation.cssClasses.LIST_ITEM_ACTIVATED_CLASS}`,
);
if (activeNavItemEl) {
activeNavItemEl.focus();
}
},
notifyClose: () => {
focusActiveNavigationItem: () => {
const activeNavItemEl = this.drawer_.querySelector(
`.${MDCListFoundation.cssClasses.LIST_ITEM_ACTIVATED_CLASS}`,
);
if (activeNavItemEl) {
activeNavItemEl.focus();
}
},
notifyClose: () => {