Skip to content

Commit

Permalink
Fix: Create class while double buffering
Browse files Browse the repository at this point in the history
  • Loading branch information
Arpita-Jaiswal authored and Heulitig committed Nov 9, 2023
1 parent 1a5d08d commit 091f631
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions fastn-js/js/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,20 @@ fastn_dom.propertyMap = {

// dynamic-class-css.md
fastn_dom.getClassesAsString = function() {
return `<style id="styles">
${fastn_dom.getClassesAsStringWithoutStyleTag()}
</style>`;
}

fastn_dom.getClassesAsStringWithoutStyleTag = function() {
let classes = Object.entries(fastn_dom.classes).map(entry => {
return getClassAsString(entry[0], entry[1]);
});

/*.ft_text {
padding: 0;
}*/
return `<style id="styles">
${classes.join("\n\t")}
</style>`;
return classes.join("\n\t");
}

function getClassAsString(className, obj) {
Expand Down Expand Up @@ -819,7 +823,6 @@ class Node2 {
});
}
}

setFavicon(url) {
if (doubleBuffering) {
if (url instanceof fastn.recordInstanceClass) url = url.get('src');
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion fastn-js/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 091f631

Please sign in to comment.