Skip to content

perf(material/icon): remove IE workaround #24514

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions src/material/icon/icon.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -877,29 +877,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 @@ -321,15 +321,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