Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
notifyChange: () => {
this.emit(MDCSelectFoundation.strings.CHANGE_EVENT, this);
if (this.ngModelCtrl_) {
this.ngModelCtrl_.$setViewValue(this.value);
}
},
getWindowInnerHeight: () => this.$window.innerHeight,
setValue: (value: string) => {
if (this.menuElement) {
const element = this.menuElement.querySelector(
`[${MDCSelectFoundation.strings.ENHANCED_VALUE_ATTR}="${value}"]`
);
const selectedIndex =
element && this.menu
? this.menu.items.indexOf(element as HTMLLIElement)
: -1;
const selectedItem = this.menu && this.menu.items[selectedIndex];
let selectedTextContent = '';
if (!!selectedItem) {
selectedTextContent =
selectedItem.dataset['label'] ||
((selectedItem.textContent && selectedItem.textContent.trim()) ||
'');
}
initialize(menuFactory = (el) => new MDCMenu(el), labelFactory = (el) => new MDCSelectLabel(el)) {
this.surface_ = this.root_.querySelector(MDCSelectFoundation.strings.SURFACE_SELECTOR);
const labelElement = this.root_.querySelector(MDCSelectFoundation.strings.LABEL_SELECTOR);
if (labelElement) {
this.label_ = labelFactory(labelElement);
}
this.bottomLine_ = this.root_.querySelector(MDCSelectFoundation.strings.BOTTOM_LINE_SELECTOR);
this.selectedText_ = this.root_.querySelector(MDCSelectFoundation.strings.SELECTED_TEXT_SELECTOR);
this.menuEl_ = this.root_.querySelector(MDCSelectFoundation.strings.MENU_SELECTOR);
this.menu_ = menuFactory(this.menuEl_);
}
getValue: () => {
let value = '';
const listItem: any =
this.menu && this.menu.items[this.state.selectedIndex];
if (
listItem &&
listItem.hasAttribute(MDCSelectFoundation.strings.ENHANCED_VALUE_ATTR)
) {
value = listItem.getAttribute(
MDCSelectFoundation.strings.ENHANCED_VALUE_ATTR
);
}
return value === '' && this.props.placeholder ? ' ' : value;
},
setValue: (value: string) => {