Skip to content

Commit 40e7904

Browse files
JeanMechekirjs
authored andcommitted
docs(docs-infra): prevent the host class from being replaced (angular#59460)
When removing the binding, the class defined on the host element is being replaced fixes angular#59442 PR Close angular#59460
1 parent f978cde commit 40e7904

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

adev/shared-docs/components/viewers/docs-viewer/docs-viewer.component.spec.ts

+7
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,13 @@ describe('DocViewer', () => {
112112

113113
expect(exampleViewer).not.toBeNull();
114114
expect(exampleViewer.componentInstance.view()).toBe(CodeExampleViewMode.SNIPPET);
115+
116+
const checkIcon = fixture.debugElement.query(By.directive(IconComponent));
117+
expect((checkIcon.nativeElement as HTMLElement).classList).toContain(
118+
`material-symbols-outlined`,
119+
);
120+
expect((checkIcon.nativeElement as HTMLElement).classList).toContain(`docs-check`);
121+
expect(checkIcon.nativeElement.innerHTML).toBe('check');
115122
});
116123

117124
it('should display example viewer in multi file mode when user clicks expand', async () => {

adev/shared-docs/components/viewers/docs-viewer/docs-viewer.component.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,12 @@ export class DocViewer implements OnChanges {
265265
}
266266

267267
private loadIcons(element: HTMLElement): void {
268-
element.querySelectorAll('docs-icon').forEach((iconsPlaceholder) => {
269-
this.renderComponent(IconComponent, iconsPlaceholder as HTMLElement);
270-
});
268+
// We need to make sure that we don't reload the icons in loadCopySourceCodeButtons
269+
element
270+
.querySelectorAll('docs-icon:not([docs-copy-source-code] docs-icon)')
271+
.forEach((iconsPlaceholder) => {
272+
this.renderComponent(IconComponent, iconsPlaceholder as HTMLElement);
273+
});
271274
}
272275

273276
/**

0 commit comments

Comments
 (0)