From 6ac36c80a3c2c8f657d2bf00cffec1009c58e05e Mon Sep 17 00:00:00 2001 From: Send_Nukez Date: Sat, 27 Nov 2021 13:23:15 +0100 Subject: [PATCH] refactor Icons.js a bit --- src/js/Icons.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/js/Icons.js b/src/js/Icons.js index f71a237..e57dfb5 100644 --- a/src/js/Icons.js +++ b/src/js/Icons.js @@ -50,23 +50,24 @@ export default class Icons { svg.attributes.width = options.size; svg.attributes.height = options.size; + // Create CSSStyleDeclaration by creating an element since there is no constructor for it + const styles = document.createElement("a").style; if (options.scale != 1) { - svg.children = svg.children.map((child) => { - child.attributes.style = `transform: scale(${options.scale}); transform-origin: center;`; - return child; - }); + styles.transform = `scale(${options.scale})`; + styles.transformOrigin = "center"; } + svg.children = svg.children.map((child) => { + child.attributes.style = styles.cssText; + return child; + }); if (options.title != null) { - console.log(options); - console.log(svg); svg.children.push({ name: "title", type: "element", value: "", children: [{ name: "", type: "text", value: options.title, attributes: {}, children: [] }] }); - console.log(svg); } if (options.base64) {