$
This commit is contained in:
24
node_modules/riot/esm/core/mount-component.js
generated
vendored
Normal file
24
node_modules/riot/esm/core/mount-component.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
/* Riot WIP, @license MIT */
|
||||
import { COMPONENTS_IMPLEMENTATION_MAP, panic } from '@riotjs/util';
|
||||
import { getName } from '../utils/dom.js';
|
||||
|
||||
/**
|
||||
* Component initialization function starting from a DOM node
|
||||
* @param {HTMLElement} element - element to upgrade
|
||||
* @param {Object} initialProps - initial component properties
|
||||
* @param {string} componentName - component id
|
||||
* @param {Array} slots - component slots
|
||||
* @returns {Object} a new component instance bound to a DOM node
|
||||
*/
|
||||
|
||||
function mountComponent(element, initialProps, componentName, slots) {
|
||||
const name = componentName || getName(element);
|
||||
if (!COMPONENTS_IMPLEMENTATION_MAP.has(name)) panic(`The component named "${name}" was never registered`);
|
||||
const component = COMPONENTS_IMPLEMENTATION_MAP.get(name)({
|
||||
props: initialProps,
|
||||
slots
|
||||
});
|
||||
return component.mount(element);
|
||||
}
|
||||
|
||||
export { mountComponent };
|
Reference in New Issue
Block a user