Skip to content

Instantly share code, notes, and snippets.

@YonatanKra
Last active September 5, 2020 08:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YonatanKra/e3f1f5068678a3c31c9652a58a951706 to your computer and use it in GitHub Desktop.
Save YonatanKra/e3f1f5068678a3c31c9652a58a951706 to your computer and use it in GitHub Desktop.
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