From 5c2f698842a0daa6ed9eb08b7ba83d378dcd1ef3 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Thu, 20 Dec 2012 09:21:58 +0000 Subject: [PATCH] Add parse tree helper for styling elements --- core/modules/utils/parsetree.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/modules/utils/parsetree.js b/core/modules/utils/parsetree.js index 44a831a33..9c5832328 100644 --- a/core/modules/utils/parsetree.js +++ b/core/modules/utils/parsetree.js @@ -29,4 +29,14 @@ exports.addClassToParseTreeNode = function(node,classString) { } }; +exports.addStyleToParseTreeNode = function(node,name,value) { + if(node.type === "element") { + node.attributes = node.attributes || {}; + node.attributes["style"] = node.attributes["style"] || {type: "string", value: ""}; + if(node.attributes["style"].type === "string") { + node.attributes["style"].value += name + ":" + value + ";"; + } + } +}; + })();