From 8ef3e59416bebc1929c059f2636d3e3f95a89d7d Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Sun, 23 Dec 2012 10:36:37 +0000 Subject: [PATCH] Improved whitespace handling in classes --- core/modules/utils/parsetree.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/modules/utils/parsetree.js b/core/modules/utils/parsetree.js index 9c5832328..a2b1428ce 100644 --- a/core/modules/utils/parsetree.js +++ b/core/modules/utils/parsetree.js @@ -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(" "); } } };