Skip to content

Instantly share code, notes, and snippets.

@YonatanKra

YonatanKra/mfa-button.js

Last active Sep 5, 2020
Embed
What would you like to do?
import { Button as MWCButton } from '@material/mwc-button';
export class MFAButton extends MWCButton {
constructor() {
super();
this.addEventListener('click', this._handleClick);
}
_handleClick(event) {
const formId = this.getAttribute('form');
const form = formId ?
document.getElementById(formId) : this.closest('form');
if (form) {
switch(this.getAttribute('type')) {
case 'reset':
form.reset();
break;
default:
form.requestSubmit();
break;
}
}
}
}
window.customElements.define('mfa-button', MFAButton);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.