1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-24 02:27:19 +00:00

Improved whitespace handling in classes

This commit is contained in:
Jeremy Ruston 2012-12-23 10:36:37 +00:00
parent c31c12d698
commit 8ef3e59416

View File

@ -20,11 +20,18 @@ exports.addAttributeToParseTreeNode = function(node,name,value) {
}; };
exports.addClassToParseTreeNode = function(node,classString) { exports.addClassToParseTreeNode = function(node,classString) {
var classes = [];
if(node.type === "element") { if(node.type === "element") {
node.attributes = node.attributes || {}; node.attributes = node.attributes || {};
node.attributes["class"] = node.attributes["class"] || {type: "string", value: ""}; node.attributes["class"] = node.attributes["class"] || {type: "string", value: ""};
if(node.attributes["class"].type === "string") { if(node.attributes["class"].type === "string") {
node.attributes["class"].value += " " + classString; if(node.attributes["class"].value !== "") {
classes = node.attributes["class"].value.split(" ");
}
if(classString !== "") {
$tw.utils.pushTop(classes,classString.split(" "));
}
node.attributes["class"].value = classes.join(" ");
} }
} }
}; };