docs(docs-infra): prevent the host class from being replaced (#59460)

When removing the binding, the class defined on the host element is being replaced

fixes #59442

PR Close #59460
This commit is contained in:
Matthieu Riegler
2025-01-10 05:41:05 +01:00
committed by kirjs
parent eb2fcd1896
commit 63ef2acc26
2 changed files with 13 additions and 3 deletions
@@ -112,6 +112,13 @@ describe('DocViewer', () => {
expect(exampleViewer).not.toBeNull();
expect(exampleViewer.componentInstance.view()).toBe(CodeExampleViewMode.SNIPPET);
const checkIcon = fixture.debugElement.query(By.directive(IconComponent));
expect((checkIcon.nativeElement as HTMLElement).classList).toContain(
`material-symbols-outlined`,
);
expect((checkIcon.nativeElement as HTMLElement).classList).toContain(`docs-check`);
expect(checkIcon.nativeElement.innerHTML).toBe('check');
});
it('should display example viewer in multi file mode when user clicks expand', async () => {
@@ -265,9 +265,12 @@ export class DocViewer implements OnChanges {
}
private loadIcons(element: HTMLElement): void {
element.querySelectorAll('docs-icon').forEach((iconsPlaceholder) => {
this.renderComponent(IconComponent, iconsPlaceholder as HTMLElement);
});
// We need to make sure that we don't reload the icons in loadCopySourceCodeButtons
element
.querySelectorAll('docs-icon:not([docs-copy-source-code] docs-icon)')
.forEach((iconsPlaceholder) => {
this.renderComponent(IconComponent, iconsPlaceholder as HTMLElement);
});
}
/**