Improved whitespace handling in classes

print-window-tiddler
Jeremy Ruston 2012-12-23 10:36:37 +00:00
rodzic c31c12d698
commit 8ef3e59416
1 zmienionych plików z 8 dodań i 1 usunięć

Wyświetl plik

@ -20,11 +20,18 @@ exports.addAttributeToParseTreeNode = function(node,name,value) {
};
exports.addClassToParseTreeNode = function(node,classString) {
var classes = [];
if(node.type === "element") {
node.attributes = node.attributes || {};
node.attributes["class"] = node.attributes["class"] || {type: "string", value: ""};
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(" ");
}
}
};