kopia lustrzana https://github.com/shoelace-style/shoelace
update helper functions
rodzic
42fb6c7100
commit
94a5c6244e
|
@ -246,16 +246,15 @@
|
|||
const allComponents = [];
|
||||
|
||||
metadata.modules.map(module => {
|
||||
module.exports.find(ex => {
|
||||
module.exports.map(ex => {
|
||||
if (ex.kind === 'custom-element-definition') {
|
||||
const tagName = ex.name;
|
||||
const className = ex.declaration.name;
|
||||
const component = Object.assign(
|
||||
{ className, tagName },
|
||||
module?.declarations.find(dec => dec.name === 'default')
|
||||
);
|
||||
const component = module?.declarations.find(dec => dec.name === 'default');
|
||||
|
||||
allComponents.push(component);
|
||||
if (component) {
|
||||
allComponents.push(Object.assign(component, { className, tagName }));
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -264,7 +263,7 @@
|
|||
}
|
||||
|
||||
function getComponent(metadata, tagName) {
|
||||
return getAllComponents(metadata).find(component => (component.tagName = tagName));
|
||||
return getAllComponents(metadata).find(component => component.tagName === tagName);
|
||||
}
|
||||
|
||||
function getMetadata() {
|
||||
|
|
|
@ -9,20 +9,19 @@ import mkdirp from 'mkdirp';
|
|||
|
||||
const metadata = JSON.parse(fs.readFileSync('./dist/custom-elements.json', 'utf8'));
|
||||
|
||||
function getAllComponents() {
|
||||
function getAllComponents(metadata) {
|
||||
const allComponents = [];
|
||||
|
||||
metadata.modules.map(module => {
|
||||
module.exports.find(ex => {
|
||||
module.exports.map(ex => {
|
||||
if (ex.kind === 'custom-element-definition') {
|
||||
const tagName = ex.name;
|
||||
const className = ex.declaration.name;
|
||||
const component = Object.assign(
|
||||
{ className, tagName },
|
||||
module?.declarations.find(dec => dec.name === 'default')
|
||||
);
|
||||
const component = module?.declarations.find(dec => dec.name === 'default');
|
||||
|
||||
allComponents.push(component);
|
||||
if (component) {
|
||||
allComponents.push(Object.assign(component, { className, tagName }));
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
Ładowanie…
Reference in New Issue