Files
webawesome/scripts/shared.js

28 lines
827 B
JavaScript
Raw Permalink Normal View History

2022-12-06 11:48:57 -05:00
/** Gets an array of components from a CEM object. */
2021-09-09 09:13:55 -04:00
export function getAllComponents(metadata) {
const allComponents = [];
metadata.modules.map(module => {
module.declarations?.map(declaration => {
if (declaration.customElement) {
const component = declaration;
2022-11-10 16:27:23 -05:00
const path = module.path;
2021-09-09 09:13:55 -04:00
if (component) {
// Calling `new Event()` adds a blank entry into the CEM, so we'll filter them out here
if (component.events) {
component.events = component.events.filter(event => {
return event.name ? true : false;
});
}
// component.events = component.events.filter(event => !!event.name);
2022-11-10 16:27:23 -05:00
allComponents.push(Object.assign(component, { path }));
2021-09-09 09:13:55 -04:00
}
}
});
});
return allComponents;
}