diff --git a/core/modules/startup.js b/core/modules/startup.js index f30589c60..9a0a217b9 100644 --- a/core/modules/startup.js +++ b/core/modules/startup.js @@ -16,6 +16,7 @@ exports.startup = function() { var modules,n,m,f,commander; // This should be somewhere else if($tw.browser) { + $tw.browser.unHyphenateCss = document.body.style["background-color"] === undefined; $tw.browser.prefix = document.body.style.webkitTransform !== undefined ? "webkit" : document.body.style.MozTransform !== undefined ? "Moz" : document.body.style.OTransform !== undefined ? "O" : null; diff --git a/core/modules/treenodes/element.js b/core/modules/treenodes/element.js index 819d53240..1609edba8 100644 --- a/core/modules/treenodes/element.js +++ b/core/modules/treenodes/element.js @@ -96,7 +96,7 @@ Element.prototype.renderInDom = function(parentDomNode,insertBefore) { element.className = v.join(" "); } else if (typeof v === "object") { // ...or objects other than style? for(var p in v) { - element.style[p] = v[p]; + element.style[$tw.utils.unHyphenateCss(p)] = v[p]; } } else { element.setAttribute(a,v); diff --git a/core/modules/utils.js b/core/modules/utils.js index 624b1b59e..8693efc75 100644 --- a/core/modules/utils.js +++ b/core/modules/utils.js @@ -299,6 +299,19 @@ exports.applyStyleSheet = function(id,css) { } }; +/* +Convert a hyphenated CSS property name into a camel case one +*/ +exports.unHyphenateCss = function(propName) { + if($tw.browser.unHyphenateCss) { + return propName.replace(/-([a-z])/gi, function(match0,match1) { + return match1.toUpperCase(); + }); + } else { + return propName; + } +}; + /* Parse a version number string of the form "1.2.3", "1.2.3.a4", or "1.2.3.b4" into: {major: , minor: , revision: , alpha: , beta: }