ember-codemod-add-component-signatures
Version:
Codemod to add component signatures
65 lines (64 loc) • 2.21 kB
JavaScript
/* https://developer.mozilla.org/docs/Web/API/HTML_DOM_API#html_dom_api_interfaces */
const defaultHtmlInterface = 'HTMLElement';
const mapping = new Map([
['a', 'HTMLAnchorElement'],
['article', 'HTMLElement'],
['aside', 'HTMLElement'],
['audio', 'HTMLAudioElement'],
['b', 'HTMLElement'],
['blockquote', 'HTMLQuoteElement'],
['button', 'HTMLButtonElement'],
['canvas', 'HTMLCanvasElement'],
['caption', 'HTMLElement'],
['code', 'HTMLElement'],
['dialog', 'HTMLDialogElement'],
['div', 'HTMLDivElement'],
['em', 'HTMLElement'],
['fieldset', 'HTMLFieldSetElement'],
['figcaption', 'HTMLElement'],
['footer', 'HTMLElement'],
['form', 'HTMLFormElement'],
['h1', 'HTMLHeadingElement'],
['h2', 'HTMLHeadingElement'],
['h3', 'HTMLHeadingElement'],
['h4', 'HTMLHeadingElement'],
['h5', 'HTMLHeadingElement'],
['h6', 'HTMLHeadingElement'],
['header', 'HTMLElement'],
['i', 'HTMLElement'],
['iframe', 'HTMLIFrameElement'],
['img', 'HTMLImageElement'],
['input', 'HTMLInputElement'],
['label', 'HTMLLabelElement'],
['legend', 'HTMLLegendElement'],
['li', 'HTMLLIElement'],
['main', 'HTMLElement'],
['nav', 'HTMLElement'],
['ol', 'HTMLOListElement'],
['optgroup', 'HTMLOptGroupElement'],
['option', 'HTMLOptionElement'],
['p', 'HTMLParagraphElement'],
['picture', 'HTMLPictureElement'],
['pre', 'HTMLElement'],
['q', 'HTMLQuoteElement'],
['section', 'HTMLElement'],
['select', 'HTMLSelectElement'],
['span', 'HTMLSpanElement'],
['strong', 'HTMLElement'],
['svg', 'SVGElement'],
['table', 'HTMLTableElement'],
['tbody', 'HTMLTableSectionElement'],
['td', 'HTMLTableCellElement'],
['textarea', 'HTMLTextAreaElement'],
['tfoot', 'HTMLTableSectionElement'],
['th', 'HTMLTableCellElement'],
['thead', 'HTMLTableSectionElement'],
['time', 'HTMLTimeElement'],
['tr', 'HTMLTableRowElement'],
['ul', 'HTMLUListElement'],
['video', 'HTMLVideoElement'],
]);
export function getHtmlInterface(elementTag) {
const htmlInterface = mapping.get(elementTag);
return htmlInterface ?? defaultHtmlInterface;
}