Skip to content

Commit e30012e

Browse files
authored
fix(docs): not setting innercontent for composition components (#4761)
* Revert "refactor: we shouldn't output the name into the innerContent in general (#4751)" This reverts commit 0279666. * fix(docs): only fix innercontent for composition components * fix(docs): only fix innercontent for composition components * Revert "fix(docs): only fix innercontent for composition components" This reverts commit 1fa7a3f. * Revert "fix(docs): only fix innercontent for composition components" This reverts commit e041cc6. * refactor: final optimization
1 parent d5c99cf commit e30012e

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

showcases/patternhub/scripts/utils.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ const getTag = (componentName) =>
7979
* @param [children] {{name:string, props: object,native?:boolean,slot?:string, angularDirective?:boolean, content?:string,children?:{name:string, props: object,native?:boolean}[]}[]}
8080
* @returns {string}
8181
*/
82+
8283
export const getCodeByFramework = (
8384
componentName,
8485
framework,
@@ -89,6 +90,13 @@ export const getCodeByFramework = (
8990
const { props, name, content, native } = example;
9091
let className = '';
9192
let tag = `DB${getTag(componentName)}`;
93+
// Self-contained or composition components
94+
const nonInnerContentComponents = [
95+
'input',
96+
'select',
97+
'textarea',
98+
'custom-select'
99+
];
92100
if (framework === 'angular') {
93101
tag = `db-${componentName}`;
94102
}
@@ -123,7 +131,10 @@ export const getCodeByFramework = (
123131
)
124132
)
125133
.join('\n') + (content ?? '')
126-
: (content ?? '');
134+
: (content ??
135+
(nonInnerContentComponents.includes(componentName)
136+
? ''
137+
: name));
127138

128139
const slots = (children ?? example.children)?.filter((child) =>
129140
child.slot

0 commit comments

Comments
 (0)