Skip to content

Commit

Permalink
perf(material/icon): remove IE workaround (#24514)
Browse files Browse the repository at this point in the history
Removes an IE-specific workaround that had some minor performance implications.

(cherry picked from commit d250b17)
  • Loading branch information
crisbeto authored and wagnermaciel committed Mar 17, 2022
1 parent 0a3c7d7 commit 5e5b296
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 32 deletions.
23 changes: 0 additions & 23 deletions src/material/icon/icon.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -846,29 +846,6 @@ describe('MatIcon', () => {
expect(svgElement.getAttribute('viewBox')).toBe('0 0 43 43');
});

it('should add an extra string to the end of `style` tags inside SVG', fakeAsync(() => {
iconRegistry.addSvgIconLiteral(
'fido',
trustHtml(`
<svg>
<style>#woof {color: blue;}</style>
<path id="woof" name="woof"></path>
</svg>
`),
);

const fixture = TestBed.createComponent(IconFromSvgName);
fixture.componentInstance.iconName = 'fido';
fixture.detectChanges();
const styleTag = fixture.nativeElement.querySelector('mat-icon svg style');

// Note the extra whitespace at the end which is what we're testing for. This is a
// workaround for IE and Edge ignoring `style` tags in dynamically-created SVGs.
expect(styleTag.textContent).toBe('#woof {color: blue;} ');

tick();
}));

it('should prepend the current path to attributes with `url()` references', fakeAsync(() => {
iconRegistry.addSvgIconLiteral(
'fido',
Expand Down
9 changes: 0 additions & 9 deletions src/material/icon/icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,15 +294,6 @@ export class MatIcon extends _MatIconBase implements OnInit, AfterViewChecked, C
private _setSvgElement(svg: SVGElement) {
this._clearSvgElement();

// Workaround for IE11 and Edge ignoring `style` tags inside dynamically-created SVGs.
// See: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10898469/
// Do this before inserting the element into the DOM, in order to avoid a style recalculation.
const styleTags = svg.querySelectorAll('style') as NodeListOf<HTMLStyleElement>;

for (let i = 0; i < styleTags.length; i++) {
styleTags[i].textContent += ' ';
}

// Note: we do this fix here, rather than the icon registry, because the
// references have to point to the URL at the time that the icon was created.
const path = this._location.getPathname();
Expand Down

0 comments on commit 5e5b296

Please sign in to comment.