UNPKG

element-vir

Version:

Heroic. Reactive. Declarative. Type safe. Web components without compromise.

20 lines (19 loc) 672 B
import { wrapDefineElement } from '../index.js'; export const defineVirElement = wrapDefineElement(); // add an optional assert callback export const defineVerifiedVirElement = wrapDefineElement({ assertInputs: (inputs) => { if (!inputs.tagName.startsWith('vir-')) { throw new Error(`all custom elements must start with "vir-"`); } }, }); // add an optional transform callback export const defineTransformedVirElement = wrapDefineElement({ transformInputs: (inputs) => { return { ...inputs, tagName: inputs.tagName.startsWith('vir-') ? `vir-${inputs.tagName}` : inputs.tagName, }; }, });