martinandert / babel-plugin-css-in-js

A plugin for Babel v6 which transforms inline styles defined in JavaScript modules into class names so they become available to, e.g. the `className` prop of React elements. While transforming, the plugin processes all JavaScript style definitions found and bundles them up into a CSS file, ready to be requested from your web server.
MIT License
299 stars 11 forks source link

String value cannot be blank #10

Closed jchristman closed 8 years ago

jchristman commented 8 years ago

On this line of transformObjectExpressionIntoStyleSheetObject, the string value is checked to see if it is blank, which is currently matching all whitespace characters.

This disallows CSS that looks like this:

const stylesheet = cssInJS({
    default: {
        ':after': {
            content: " "    // There is a an empty space here so that the pseudo element renders
        }
    }
});

This is needed to do some styling things where content is not necessary for the pseudo element. A change that would fix this problem is simply:

    assert(val.length >= 1, 'string value cannot be blank');

instead of the isBlank call. This still prevents empty strings, but allows deliberately white space strings for CSS properties.

martinandert commented 8 years ago

@jchristman Thanks for spotting!

This issue has been addressed in v1.2.3

jchristman commented 8 years ago

Excellent - thanks for the quick fix!