From 8722c2aa7b556d340a6f6fd4cae26d5a7602ad20 Mon Sep 17 00:00:00 2001 From: Victor Saiz Date: Fri, 19 Aug 2016 09:37:04 +0200 Subject: [PATCH 1/2] performance optimisations --- src/components/themr.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/components/themr.js b/src/components/themr.js index 1ea0ca7..945c9f8 100644 --- a/src/components/themr.js +++ b/src/components/themr.js @@ -84,11 +84,12 @@ export default (componentName, localTheme, options = {}) => (ThemedComponent) => function themeable(style = {}, theme) { if (!theme) return style - return [ ...Object.keys(theme), ...Object.keys(style) ].reduce((result, key) => ( - typeof theme[key] === 'string' && style[key] && theme[key].indexOf(style[key]) === -1 - ? { ...result, [key]: `${style[key]} ${theme[key]}` } - : { ...result, [key]: theme[key] || style[key] } - ), {}) + return Object.keys(theme).reduce((result, key) => ( + Object.assign(result, + style[key] && theme[key].indexOf(style[key]) === -1 + ? { [key]: `${style[key]} ${theme[key]}` } + : { [key]: theme[key] || style[key] } + )), style) } function validateComposeOption(composeTheme) { From b758730b7c0ff7e9af60f14ac0e69d1b84fb9d95 Mon Sep 17 00:00:00 2001 From: Victor Saiz Date: Fri, 19 Aug 2016 09:50:24 +0200 Subject: [PATCH 2/2] more concise version --- src/components/themr.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/themr.js b/src/components/themr.js index 945c9f8..aaa4d8c 100644 --- a/src/components/themr.js +++ b/src/components/themr.js @@ -85,11 +85,11 @@ export default (componentName, localTheme, options = {}) => (ThemedComponent) => function themeable(style = {}, theme) { if (!theme) return style return Object.keys(theme).reduce((result, key) => ( - Object.assign(result, - style[key] && theme[key].indexOf(style[key]) === -1 - ? { [key]: `${style[key]} ${theme[key]}` } - : { [key]: theme[key] || style[key] } - )), style) + Object.assign(result, { [key]: + style[key] && theme[key].indexOf(style[key]) === -1 + ? `${style[key]} ${theme[key]}` + : theme[key] || style[key] + })), style) } function validateComposeOption(composeTheme) {