Skip to content

Commit 5e5b296

Browse files
crisbetowagnermaciel
authored andcommitted
perf(material/icon): remove IE workaround (#24514)
Removes an IE-specific workaround that had some minor performance implications. (cherry picked from commit d250b17)
1 parent 0a3c7d7 commit 5e5b296

File tree

2 files changed

+0
-32
lines changed

2 files changed

+0
-32
lines changed

src/material/icon/icon.spec.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -846,29 +846,6 @@ describe('MatIcon', () => {
846846
expect(svgElement.getAttribute('viewBox')).toBe('0 0 43 43');
847847
});
848848

849-
it('should add an extra string to the end of `style` tags inside SVG', fakeAsync(() => {
850-
iconRegistry.addSvgIconLiteral(
851-
'fido',
852-
trustHtml(`
853-
<svg>
854-
<style>#woof {color: blue;}</style>
855-
<path id="woof" name="woof"></path>
856-
</svg>
857-
`),
858-
);
859-
860-
const fixture = TestBed.createComponent(IconFromSvgName);
861-
fixture.componentInstance.iconName = 'fido';
862-
fixture.detectChanges();
863-
const styleTag = fixture.nativeElement.querySelector('mat-icon svg style');
864-
865-
// Note the extra whitespace at the end which is what we're testing for. This is a
866-
// workaround for IE and Edge ignoring `style` tags in dynamically-created SVGs.
867-
expect(styleTag.textContent).toBe('#woof {color: blue;} ');
868-
869-
tick();
870-
}));
871-
872849
it('should prepend the current path to attributes with `url()` references', fakeAsync(() => {
873850
iconRegistry.addSvgIconLiteral(
874851
'fido',

src/material/icon/icon.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -294,15 +294,6 @@ export class MatIcon extends _MatIconBase implements OnInit, AfterViewChecked, C
294294
private _setSvgElement(svg: SVGElement) {
295295
this._clearSvgElement();
296296

297-
// Workaround for IE11 and Edge ignoring `style` tags inside dynamically-created SVGs.
298-
// See: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10898469/
299-
// Do this before inserting the element into the DOM, in order to avoid a style recalculation.
300-
const styleTags = svg.querySelectorAll('style') as NodeListOf<HTMLStyleElement>;
301-
302-
for (let i = 0; i < styleTags.length; i++) {
303-
styleTags[i].textContent += ' ';
304-
}
305-
306297
// Note: we do this fix here, rather than the icon registry, because the
307298
// references have to point to the URL at the time that the icon was created.
308299
const path = this._location.getPathname();

0 commit comments

Comments
 (0)