Skip to content

Commit

Permalink
fix: using unsafeSVG and a template (#1561)
Browse files Browse the repository at this point in the history
  • Loading branch information
dlockhart authored Aug 3, 2021
1 parent b75ba17 commit 0a1c141
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions components/icons/icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { iconStyles } from './icon-styles.js';
import { loadSvg } from '../../generated/icons/presetIconLoader.js';
import { RtlMixin } from '../../mixins/rtl-mixin.js';
import { runAsync } from '../../directives/run-async.js';
import { unsafeHTML } from 'lit-html/directives/unsafe-html.js';
import { unsafeSVG } from 'lit-html/directives/unsafe-svg.js';

class Icon extends RtlMixin(LitElement) {

Expand Down Expand Up @@ -47,13 +47,13 @@ class Icon extends RtlMixin(LitElement) {
return undefined;
}

const elem = document.createElement('div');
elem.innerHTML = svgStr;
const template = document.createElement('template');
template.innerHTML = svgStr;

const svg = elem.firstChild;
const svg = template.content.firstChild;
fixSvg(svg);

return html`${unsafeHTML(elem.innerHTML)}`;
return html`${unsafeSVG(template.innerHTML)}`;

}

Expand Down

0 comments on commit 0a1c141

Please sign in to comment.