17 lines
470 B
JavaScript
17 lines
470 B
JavaScript
|
class svgLoad extends HTMLElement {
|
||
|
constructor(){
|
||
|
super();
|
||
|
let svgName = this.getAttribute("data-name");
|
||
|
let xhr = new XMLHttpRequest();
|
||
|
xhr.onreadystatechange = () => {
|
||
|
if(xhr.readyState === 4 && xhr.status === 200){
|
||
|
this.innerHTML = xhr.responseText;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
xhr.open("GET", "/img/svg/" + svgName + ".svg");
|
||
|
xhr.send();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
customElements.define("jl-svg", svgLoad);
|