diff --git a/src/core/compile.js b/src/core/compile.js index 83363d6f..59696dad 100644 --- a/src/core/compile.js +++ b/src/core/compile.js @@ -33,9 +33,9 @@ export let compile = (str, defs, data) => { // Here we check if this is strictly a boolean with false value // define it as `''` to be picked up as empty, otherwise use // res value - tail = res === false ? '' : res; + tail = res; } } - return out + next + (tail == null ? '' : tail); + return out + next + (tail == null || tail === false ? '' : tail); }, ''); }; diff --git a/src/core/hash.js b/src/core/hash.js index 6d3b5143..c37fa0b5 100644 --- a/src/core/hash.js +++ b/src/core/hash.js @@ -40,21 +40,28 @@ export let hash = (compiled, sheet, global, append, keyframes) => { let className = cache[stringifiedCompiled] || (cache[stringifiedCompiled] = toHash(stringifiedCompiled)); - // If there's no entry for the current className - if (!cache[className]) { - // Build the _ast_-ish structure if needed - let ast = stringifiedCompiled !== compiled ? compiled : astish(compiled); - - // Parse it - cache[className] = parse( - // For keyframes - keyframes ? { ['@keyframes ' + className]: ast } : ast, - global ? '' : '.' + className - ); - } - // add or update - update(cache[className], sheet, append); + update( + (cache[className] = + cache[className] || + // If there's no entry for the current className + // Parse it + parse( + // For keyframes + keyframes + ? // Build the _ast_-ish structure if needed + { + ['@keyframes ' + className]: + stringifiedCompiled !== compiled ? compiled : astish(compiled) + } + : stringifiedCompiled !== compiled + ? compiled + : astish(compiled), + global ? '' : '.' + className + )), + sheet, + append + ); // return hash return className; diff --git a/src/core/parse.js b/src/core/parse.js index fb05f852..90250557 100644 --- a/src/core/parse.js +++ b/src/core/parse.js @@ -43,7 +43,7 @@ export let parse = (obj, selector) => { }) : key ); - } else if (val != undefined) { + } else if (val +1 ) { // Convert all but CSS variables key = /^--/.test(key) ? key : key.replace(/[A-Z]/g, '-$&').toLowerCase(); // Push the line for this property diff --git a/src/core/update.js b/src/core/update.js index bc21891c..f8a4b058 100644 --- a/src/core/update.js +++ b/src/core/update.js @@ -17,5 +17,5 @@ export let extractCss = (target) => { * @param {Boolean} append */ export let update = (css, sheet, append) => { - sheet.data.indexOf(css) == -1 && (sheet.data = append ? css + sheet.data : sheet.data + css); + ~sheet.data.indexOf(css) || (sheet.data = append ? css + sheet.data : sheet.data + css); }; diff --git a/src/styled.js b/src/styled.js index 65bd6682..8b3b240e 100644 --- a/src/styled.js +++ b/src/styled.js @@ -48,15 +48,11 @@ function styled(tag, forwardRef) { } // Assign the _as with the provided `tag` value - let _as = tag; - // If this is a string -- checking that is has a first valid char - if (tag[0]) { - // Try to assign the _as with the given _as value if any - _as = _props.as || tag; - // And remove it - delete _props.as; - } + // Try to assign the _as with the given _as value if any + let _as = (tag[0] && _props.as) || tag; + // And remove it + tag[0] && delete _props.as; // Handle the forward props filter if defined and _as is a string if (fwdProp && _as[0]) {