Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
dermatthes committed Oct 1, 2023
1 parent 44db2e6 commit a5ca7a7
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
],
"author": "",
"dependencies": {
"@kasimirjs/embed": "^1.1.6"
"@kasimirjs/embed": "^1.1.8"
},
"devDependencies": {
"dart-sass": "^1.25.0",
Expand Down
35 changes: 33 additions & 2 deletions src/processor/jodastyle-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,39 @@ jodaStyleCommands["--joda-use"] = async(value : string, target, element : HTMLEl
});
let newElement = await getTemplateFilledWithContent(value, placeholder, element);

element.append(newElement);
return element;
console.log("new: ", newElement, newElement.firstElementChild);



let firstElement = newElement.firstElementChild;
firstElement["joda-style-processed"] = true; // Set style as processed (to prevent double processing)

// Copy first line of the outerHTML string of the element
let debugElement = element.outerHTML.split("\n")[0];
firstElement.setAttribute("_orig_elem", debugElement);


element.getAttributeNames().forEach((attrName) => {

// copy attributes but. Append class and styles
if (attrName === "class") {
firstElement.setAttribute(attrName, element.getAttribute(attrName) + " " + firstElement.getAttribute(attrName) ?? "");
return;
}
if (attrName === "style") {
firstElement.setAttribute(attrName, element.getAttribute(attrName) + " " + firstElement.getAttribute(attrName) ?? "");
return;
}
if(attrName.startsWith("layout")) {
firstElement.setAttribute("layout-orig", element.getAttribute(attrName));
return;
}

firstElement.setAttribute(attrName, element.getAttribute(attrName));
});
element.parentElement.insertBefore(newElement, element);
element.parentElement.removeChild(element);
return firstElement;
}


Expand Down

0 comments on commit a5ca7a7

Please sign in to comment.