$
This commit is contained in:
40
node_modules/riot/esm/core/instantiate-component.js
generated
vendored
Normal file
40
node_modules/riot/esm/core/instantiate-component.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
/* Riot WIP, @license MIT */
|
||||
import { defineProperties, defineDefaults, PROPS_KEY, STATE_KEY, SLOTS_KEY, ROOT_KEY } from '@riotjs/util';
|
||||
import { COMPONENT_DOM_SELECTORS } from './component-dom-selectors.js';
|
||||
import { COMPONENT_LIFECYCLE_METHODS } from './component-lifecycle-methods.js';
|
||||
import cssManager from './css-manager.js';
|
||||
import curry from 'curri';
|
||||
import { manageComponentLifecycle } from './manage-component-lifecycle.js';
|
||||
|
||||
/**
|
||||
* Component definition function
|
||||
* @param {Object} implementation - the component implementation will be generated via compiler
|
||||
* @param {Object} component - the component initial properties
|
||||
* @returns {Object} a new component implementation object
|
||||
*/
|
||||
|
||||
function instantiateComponent(_ref) {
|
||||
let {
|
||||
css,
|
||||
template,
|
||||
componentAPI,
|
||||
name
|
||||
} = _ref;
|
||||
// add the component css into the DOM
|
||||
if (css && name) cssManager.add(name, css);
|
||||
return curry(manageComponentLifecycle)(defineProperties( // set the component defaults without overriding the original component API
|
||||
defineDefaults(componentAPI, Object.assign({}, COMPONENT_LIFECYCLE_METHODS, {
|
||||
[PROPS_KEY]: {},
|
||||
[STATE_KEY]: {}
|
||||
})), Object.assign({
|
||||
// defined during the component creation
|
||||
[SLOTS_KEY]: null,
|
||||
[ROOT_KEY]: null
|
||||
}, COMPONENT_DOM_SELECTORS, {
|
||||
name,
|
||||
css,
|
||||
template
|
||||
})));
|
||||
}
|
||||
|
||||
export { instantiateComponent };
|
Reference in New Issue
Block a user