Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected createAdapter(): MDCSliderAdapter {
return {
...addHasRemoveClass(this.mdcRoot),
getAttribute: (name: string) => this.mdcRoot.getAttribute(name),
setAttribute: (name: string, value: string) =>
this.mdcRoot.setAttribute(name, value),
removeAttribute: (name: string) => this.mdcRoot.removeAttribute(name),
computeBoundingRect: () => this.mdcRoot.getBoundingClientRect(),
getTabIndex: () => this.mdcRoot.tabIndex,
registerInteractionHandler:
(type: K, handler: SpecificEventListener) => {
const init = type === 'touchstart' ? applyPassive() : undefined;
this.mdcRoot.addEventListener(type, handler, init);
},
deregisterInteractionHandler:
(type: K, handler: SpecificEventListener) =>
this.mdcRoot.removeEventListener(type, handler),
registerThumbContainerInteractionHandler:
(type: K, handler: SpecificEventListener) => {
.filter((attributeName) => attributeName) as string[];
};
const observer = new MutationObserver((mutationsList) => {
const attributes = getAttributesList(mutationsList);
if (attributes.indexOf('maxlength') !== -1 && this.maxLength !== -1) {
this.charCounterElement.charCounterFoundation.setCounterValue(
this.value.length, this.maxLength);
}
});
const config = {attributes: true};
observer.observe(this.formElement, config);
return observer;
},
deregisterValidationAttributeChangeHandler:
(observer: MutationObserver) => observer.disconnect(),
...addHasRemoveClass(this.mdcRoot),
};
}
createAdapter(): MDCSelectAdapter {
this.createListFoundation();
this.createMenuSurfaceFoundation();
this.createMenuFoundation();
return {
...addHasRemoveClass(this.mdcRoot),
activateBottomLine: () => {
if (this.lineRippleElement) {
this.lineRippleElement.lineRippleFoundation.activate();
}
},
deactivateBottomLine: () => {
if (this.lineRippleElement) {
this.lineRippleElement.lineRippleFoundation.deactivate();
}
},
getSelectedMenuItem: () => {
const listElement = this.listElement;
if (!listElement) {
return null;
}
protected createAdapter(): MDCTextFieldAdapter {
return {
...addHasRemoveClass(this.mdcRoot),
...this.getRootAdapterMethods(),
...this.getInputAdapterMethods(),
...this.getLabelAdapterMethods(),
...this.getLineRippleAdapterMethods(),
...this.getOutlineAdapterMethods(),
};
}
createMenuSurfaceFoundation() {
if (!this.menuElement) {
return;
}
if (this.mdcMenuSurfaceFoundation) {
this.mdcMenuSurfaceFoundation.destroy();
}
const mdcMenuSurfaceAdapter: MDCMenuSurfaceAdapter = {
...addHasRemoveClass(this.menuElement),
hasAnchor: () => {
if (!this.menuElement) {
return false;
}
return !!mwcMenu.anchorElement(this.menuElement);
},
notifyClose: () => {
if (!this.menuElement) {
return;
}
const init: CustomEventInit = {};
const ev = new CustomEvent('closed', init);
this.menuElement.dispatchEvent(ev);
},
protected createAdapter(): MDCSwitchAdapter {
return {
...addHasRemoveClass(this.mdcRoot),
setNativeControlChecked: (checked: boolean) => {
this.formElement.checked = checked;
},
setNativeControlDisabled: (disabled: boolean) => {
this.formElement.disabled = disabled;
},
};
}
protected createAdapter(): MDCCheckboxAdapter {
return {
...addHasRemoveClass(this.mdcRoot),
forceLayout: () => {
this.mdcRoot.offsetWidth;
},
isAttachedToDOM: () => this.isConnected,
isIndeterminate: () => this.indeterminate,
isChecked: () => this.checked,
hasNativeControl: () => Boolean(this.formElement),
setNativeControlDisabled: (disabled: boolean) => {
this.formElement.disabled = disabled;
},
setNativeControlAttr: (attr: string, value: string) => {
this.formElement.setAttribute(attr, value);
},
removeNativeControlAttr: (attr: string) => {
this.formElement.removeAttribute(attr);
},