File tree Expand file tree Collapse file tree 2 files changed +1286
-1283
lines changed Expand file tree Collapse file tree 2 files changed +1286
-1283
lines changed Original file line number Diff line number Diff line change @@ -2,14 +2,15 @@ import { svg } from "svg-sprites/sheet";
2
2
3
3
let svgSheet : HTMLDivElement ;
4
4
let supportsAdoptingStyleSheets = true ;
5
+ let loaded : Promise < void > ;
5
6
6
7
async function loadSvgSheet ( ) {
7
8
svgSheet = document . createElement ( "div" ) ;
8
9
svgSheet . innerHTML = await svg ( ) ;
9
10
}
10
11
11
12
if ( typeof window !== "undefined" ) {
12
- loadSvgSheet ( ) ;
13
+ loaded = loadSvgSheet ( ) ;
13
14
14
15
supportsAdoptingStyleSheets =
15
16
globalThis . ShadowRoot &&
@@ -63,9 +64,11 @@ export class FraIcon extends HTMLElement {
63
64
if ( icon !== null ) this . setAttribute ( "name" , icon ) ;
64
65
}
65
66
66
- attributeChangedCallback ( ) : void {
67
- const name = this . name ;
68
- const symbol = svgSheet . querySelector ( `#${ name } ` ) ;
67
+ async attributeChangedCallback ( ) {
68
+ await loaded ;
69
+
70
+ const symbol = svgSheet . querySelector ( `#${ this . name ?. replace ( / \/ / g, "\\/" ) } ` ) ;
71
+
69
72
if ( this . shadowRoot && symbol ) {
70
73
this . shadowRoot . innerHTML = /*html*/ `
71
74
<svg viewBox="${ symbol . getAttribute ( "viewBox" ) } " aria-hidden="true">
You can’t perform that action at this time.
0 commit comments