Skip to content

Commit 0a1c141

Browse files
authored
fix: using unsafeSVG and a template (#1561)
1 parent b75ba17 commit 0a1c141

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

components/icons/icon.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { iconStyles } from './icon-styles.js';
55
import { loadSvg } from '../../generated/icons/presetIconLoader.js';
66
import { RtlMixin } from '../../mixins/rtl-mixin.js';
77
import { runAsync } from '../../directives/run-async.js';
8-
import { unsafeHTML } from 'lit-html/directives/unsafe-html.js';
8+
import { unsafeSVG } from 'lit-html/directives/unsafe-svg.js';
99

1010
class Icon extends RtlMixin(LitElement) {
1111

@@ -47,13 +47,13 @@ class Icon extends RtlMixin(LitElement) {
4747
return undefined;
4848
}
4949

50-
const elem = document.createElement('div');
51-
elem.innerHTML = svgStr;
50+
const template = document.createElement('template');
51+
template.innerHTML = svgStr;
5252

53-
const svg = elem.firstChild;
53+
const svg = template.content.firstChild;
5454
fixSvg(svg);
5555

56-
return html`${unsafeHTML(elem.innerHTML)}`;
56+
return html`${unsafeSVG(template.innerHTML)}`;
5757

5858
}
5959

0 commit comments

Comments
 (0)