From 091f63181478d527672aad95f8c3e6144e9135f3 Mon Sep 17 00:00:00 2001 From: Arpita-Jaiswal Date: Thu, 9 Nov 2023 17:52:15 +0530 Subject: [PATCH] Fix: Create class while double buffering --- fastn-js/js/dom.js | 13 ++++++++----- fastn-js/js/utils.js | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/fastn-js/js/dom.js b/fastn-js/js/dom.js index f6b15f5169..fe98894cd3 100644 --- a/fastn-js/js/dom.js +++ b/fastn-js/js/dom.js @@ -119,6 +119,12 @@ fastn_dom.propertyMap = { // dynamic-class-css.md fastn_dom.getClassesAsString = function() { + return ``; +} + +fastn_dom.getClassesAsStringWithoutStyleTag = function() { let classes = Object.entries(fastn_dom.classes).map(entry => { return getClassAsString(entry[0], entry[1]); }); @@ -126,9 +132,7 @@ fastn_dom.getClassesAsString = function() { /*.ft_text { padding: 0; }*/ - return ``; + return classes.join("\n\t"); } function getClassAsString(className, obj) { @@ -819,7 +823,6 @@ class Node2 { }); } } - setFavicon(url) { if (doubleBuffering) { if (url instanceof fastn.recordInstanceClass) url = url.get('src'); @@ -989,7 +992,7 @@ class Node2 { return cls; } - if (!ssr) { + if (!ssr && !doubleBuffering) { if (!!className) { if (!fastn_dom.classes[cssClass]) { fastn_dom.classes[cssClass] = fastn_dom.classes[cssClass] || obj; diff --git a/fastn-js/js/utils.js b/fastn-js/js/utils.js index eea18da5b1..bef1085255 100644 --- a/fastn-js/js/utils.js +++ b/fastn-js/js/utils.js @@ -537,7 +537,7 @@ let fastn_utils = { replaceBodyStyleAndChildren(newChildrenWrapper) { // Update styles based on `fastn_dom.styleClasses` let styles = document.getElementById("styles"); - styles.innerHTML = fastn_dom.styleClasses; + styles.innerHTML = fastn_dom.getClassesAsStringWithoutStyleTag(); // Replace the children of document.body with the children from // newChildrenWrapper