Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private getListItemIndex_(evt: Event) {
const eventTarget = evt.target as Element;
const nearestParent = closest(eventTarget, `.${cssClasses.LIST_ITEM_CLASS}, .${cssClasses.ROOT}`);
// Get the index of the element if it is a list item.
if (nearestParent && matches(nearestParent, `.${cssClasses.LIST_ITEM_CLASS}`)) {
return this.listElements.indexOf(nearestParent);
}
return -1;
}
eventTargetMatchesSelector: (evtTarget, selector) => {
return matches(evtTarget, selector);
},
addClass: className => this.$set(this.classes, className, true),
export function findAssignedElement(slot: HTMLSlotElement, selector: string) {
for (const node of slot.assignedNodes({flatten: true})) {
if (node.nodeType === Node.ELEMENT_NODE) {
const el = (node as HTMLElement);
if (matches(el, selector)) {
return el;
}
}
}
return null;
}
isSurfaceActive: () => {
return matches(vm.$el, ':active');
},
isSurfaceDisabled: () => {
eventTargetMatchesSelector: (evtTarget: HTMLElement, selector: string) => matches(evtTarget, selector),
addClass: (className: string) => this._getHostElement().classList.add(className),
isSurfaceActive: () => {
if (activator) {
return matches(activator, ':active');
}
return matches(surface, ':active');
},
isSurfaceDisabled: () => this.props.disabled as boolean,
eventTargetMatchesSelector: (evtTarget, selector) => matches(evtTarget as Element, selector),
addClass: (className) => this.root_.classList.add(className),
isSurfaceActive: () => matches(instance._root, ':active'),
isSurfaceDisabled: () => coerceBooleanProperty(instance.disabled),
eventTargetMatches: (target, selector) =>
target ? matches(target as Element, selector) : false,
getActionFromEvent: (e: Event) => {
isSurfaceActive: () => matches(instance.root_, ':active'),
isSurfaceDisabled: () => Boolean(instance.disabled),