Skip to content

Commit

Permalink
fix(ui): fixed broken HtmlSectionComponent story
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksandr Beliaev committed Apr 10, 2024
1 parent a225eda commit d9b3331
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions libs/ui/src/lib/html-section/html-section.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,22 @@ import { AllowedAttribute } from 'sanitize-html';
export class HtmlSectionComponent implements OnInit {
@Input() html = '';
@Input() sanitize = true;

/** @internal */
@Input() customElements: [any, string][] = [
[LabeledIconComponent, 'cvi-web-labeled-icon'],
[IconComponent, 'cvi-web-icon'],
[TrackComponent, 'cvi-web-track'],
];

/** @internal */
@Input() allowedTags: string[] = [
'cvi-web-labeled-icon',
'cvi-web-icon',
'cvi-web-track',
];

/** @internal */
@Input() allowedAttributes: Record<string, AllowedAttribute[]> = {
'cvi-web-labeled-icon': ['name'],
'cvi-web-icon': ['name'],
Expand Down Expand Up @@ -64,13 +70,15 @@ export class HtmlSectionComponent implements OnInit {
}

private createCustomElements(elements: [any, string][]) {
elements
.filter(([, name]) => !customElements.get(name))
.forEach(([component, name]) => {
const element = createCustomElement(component, {
injector: this.injector,
if (elements) {
elements
.filter(([_, name]) => !customElements.get(name))
.forEach(([component, name]) => {
const element = createCustomElement(component, {
injector: this.injector,
});
customElements.define(name, element);
});
customElements.define(name, element);
});
}
}
}

0 comments on commit d9b3331

Please sign in to comment.