Skip to content

Commit

Permalink
fix(docs-infra): correctly display SVG icons in IE11 (angular#38046)
Browse files Browse the repository at this point in the history
Fix two issues that affected displaying of SVG icons in IE11:

1. All SVG icons except for one appeared empty. This was related how the
CustomIconRegistry re-used the same <div> element to create all
SVG elements.

2. The GitHub and Twitter buttons next to the search bar were not sized
properly.

Fixes angular#37847

PR Close angular#38046
  • Loading branch information
saifabusaleh authored and AndrewKushnir committed Jul 17, 2020
1 parent fd45f74 commit b3b03c3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion aio/src/app/shared/custom-icon-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ export class CustomIconRegistry extends MatIconRegistry {
}

private loadSvgElements(svgIcons: SvgIconInfo[]) {
const div = document.createElement('DIV');
svgIcons.forEach(icon => {
const ns = icon.namespace || DEFAULT_NS;
const nsIconMap = this.preloadedSvgElements[ns] || (this.preloadedSvgElements[ns] = {});

// Creating a new `<div>` per icon is necessary for the SVGs to work correctly in IE11.
const div = document.createElement('DIV');

// SECURITY: the source for the SVG icons is provided in code by trusted developers
div.innerHTML = icon.svgSource;

Expand Down
1 change: 1 addition & 0 deletions aio/src/styles/1-layouts/_top-menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ aio-search-box.search-container {
.toolbar-external-icons-container {
display: flex;
flex-direction: row;
flex-shrink: 0; // This is required for the icons to be displayed correctly in IE11.
height: 100%;

a {
Expand Down

0 comments on commit b3b03c3

Please sign in to comment.