From b91a1eccf3152f8eff21b8919b5fdf011fdd059d Mon Sep 17 00:00:00 2001 From: Marc Trudel Date: Tue, 9 Oct 2012 19:41:04 +0900 Subject: [PATCH] [api] Added ability to set styles via array. Closes #27 --- colors.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/colors.js b/colors.js index 7336ed0..846e861 100644 --- a/colors.js +++ b/colors.js @@ -121,10 +121,22 @@ function applyTheme(theme) { Object.keys(theme).forEach(function (prop) { if (stringPrototypeBlacklist.indexOf(prop) !== -1) { console.log('warn: '.red + ('String.prototype' + prop).magenta + ' is probably something you don\'t want to override. Ignoring style name'); - } else { - addProperty(prop, function () { - return exports[theme[prop]](this); - }); + } + else { + if (typeof(theme[prop]) === 'string') { + addProperty(prop, function () { + return exports[theme[prop]](this); + }); + } + else { + addProperty(prop, function () { + var ret = this; + for (var t = 0; t < theme[prop].length; t++) { + ret = exports[theme[prop][t]](ret); + } + return ret; + }); + } } }); }