UNPKG

riot

Version:

Simple and elegant component-based UI library

25 lines (20 loc) 827 B
/* Riot v9.4.9, @license MIT */ import { COMPONENTS_IMPLEMENTATION_MAP } from '../dependencies/@riotjs/util/constants.js'; import { panic } from '../dependencies/@riotjs/util/misc.js'; import { createComponentFromWrapper } from '../core/create-component-from-wrapper.js'; /** * Register a custom tag by name * @param {string} name - component name * @param {Object} implementation - tag implementation * @returns {Map} map containing all the components implementations */ function register(name, { css, template, exports }) { if (COMPONENTS_IMPLEMENTATION_MAP.has(name)) panic(`The component "${name}" was already registered`); COMPONENTS_IMPLEMENTATION_MAP.set( name, createComponentFromWrapper({ name, css, template, exports }), ); return COMPONENTS_IMPLEMENTATION_MAP } export { register };