Skip to content

Commit 07438ba

Browse files
authored
Additional fixes to getComponentsFromDefs (#6342)
1 parent b833ae9 commit 07438ba

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

packages/core/src/dom_components/model/Components.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,20 @@ const getComponentsFromDefs = (
6363
}
6464
}
6565

66+
// Here `result` might be a Component
67+
const cmp = isFunction(result.components) ? (result as unknown as Component) : null;
68+
6669
if (components) {
6770
const newComponents = getComponentsFromDefs(components, all, opts);
6871

69-
if (isFunction(result.components)) {
70-
const cmps = result.components();
71-
cmps.length > 0 && cmps.reset(newComponents, opts);
72+
if (cmp) {
73+
cmp.components().reset(newComponents, opts);
7274
} else {
7375
result.components = newComponents;
7476
}
77+
} else if (cmp) {
78+
// The component already exists but the parsed one is without components
79+
cmp.components().reset([], opts);
7580
}
7681

7782
return result;

0 commit comments

Comments
 (0)