diff --git a/lib/extendStringPrototype.js b/lib/extendStringPrototype.js index ed608f6..6d6bbfe 100644 --- a/lib/extendStringPrototype.js +++ b/lib/extendStringPrototype.js @@ -73,18 +73,16 @@ module['exports'] = function() { } else { if (typeof(theme[prop]) === 'string') { colors[prop] = colors[theme[prop]]; - addProperty(prop, function() { - return colors[theme[prop]](this); - }); } else { - addProperty(prop, function() { - var ret = this; - for (var t = 0; t < theme[prop].length; t++) { - ret = colors[theme[prop][t]](ret); - } - return ret; - }); + var tmp = colors[theme[prop][0]]; + for (var t = 1; t < theme[prop].length; t++) { + tmp = tmp[theme[prop][t]]; + } + colors[prop] = tmp; } + addProperty(prop, function() { + return colors[prop](this); + }); } }); }