From dc4cad858a929039a9120abead3f6d84c83b7c9d Mon Sep 17 00:00:00 2001 From: Arpita-Jaiswal Date: Wed, 25 Oct 2023 18:48:44 +0530 Subject: [PATCH] Style fixes --- fastn-js/js/dom.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/fastn-js/js/dom.js b/fastn-js/js/dom.js index 1dec843463..90856f2c01 100644 --- a/fastn-js/js/dom.js +++ b/fastn-js/js/dom.js @@ -938,7 +938,13 @@ class Node2 { if (!fastn_dom.classes[cssClass]) { fastn_dom.classes[cssClass] = fastn_dom.classes[cssClass] || obj; let styles = document.getElementById('styles'); - styles.innerHTML = `${styles.innerHTML}${getClassAsString(cssClass, obj)}\n`; + let newClasses = getClassAsString(cssClass, obj); + let textNode = document.createTextNode(newClasses); + if (styles.styleSheet) { + styles.styleSheet.cssText = newClasses; + } else { + styles.appendChild(textNode); + } } return cls; } @@ -953,7 +959,13 @@ class Node2 { if (!fastn_dom.classes[cssClass]) { fastn_dom.classes[cssClass] = fastn_dom.classes[cssClass] || obj; let styles = document.getElementById('styles'); - styles.innerHTML = `${styles.innerHTML}${getClassAsString(cssClass, obj)}\n`; + let newClasses = getClassAsString(cssClass, obj); + let textNode = document.createTextNode(newClasses); + if (styles.styleSheet) { + styles.styleSheet.cssText = newClasses; + } else { + styles.appendChild(textNode); + } } this.#node.style.removeProperty(property); this.#node.classList.add(cls);