Skip to content

Commit

Permalink
Review feedback
Browse files Browse the repository at this point in the history
Co-authored-by: David Ortner <david@ortner.se>
  • Loading branch information
fsoikin and capricorn86 committed Oct 6, 2022
1 parent c7bee3c commit 8d0adf6
Showing 1 changed file with 7 additions and 3 deletions.
@@ -1,7 +1,11 @@
import HTMLElement from '../html-element/HTMLElement';
import IHTMLButtonElement from './IHTMLButtonElement';

const BUTTON_TYPES = ['submit', 'reset', 'button', 'menu'];

/**
We can improve performance a bit if we make the types as a constant.
* HTML Button Element.
*
* Reference:
Expand Down Expand Up @@ -54,7 +58,7 @@ export default class HTMLButtonElement extends HTMLElement implements IHTMLButto
* @returns Type
*/
public get type(): string {
return this.sanitizeType(this.getAttributeNS(null, 'type'));
return this._sanitizeType(this.getAttributeNS(null, 'type'));
}

/**
Expand All @@ -70,10 +74,10 @@ export default class HTMLButtonElement extends HTMLElement implements IHTMLButto
*
* @param type
*/
private sanitizeType(type: string): string {
protected _sanitizeType(type: string): string {
type = (type && type.toLowerCase()) || 'submit';

if (!['submit', 'reset', 'button', 'menu'].includes(type)) {
if (! BUTTON_TYPES.includes(type)) {
type = 'submit';
}

Expand Down

0 comments on commit 8d0adf6

Please sign in to comment.