CSSJSON icon indicating copy to clipboard operation
CSSJSON copied to clipboard

Last style ignored if no trailing semi-colon

Open iconifyit opened this issue 4 years ago • 0 comments

In CSS, the trailing terminator (semi-colon) is not required for the last rule. In your code, if the last rule is not terminated with a semi-colon it does not get parsed.

For instance:

 '.st5{fill:none;stroke:#45413c;stroke-linecap:round;stroke-linejoin:round}'

Will be parsed to :

{ '.st5': { 
    children: {},
    attributes: { 
        fill: 'none',
        stroke: '#45413c',
        'stroke-linecap': 'round',
        'stroke-linejoin': 'round' 
}}}

Notice that the rule stroke-linejoin:round is missing. However, if I terminate the rule with a semi-colon, it is parse correctly.

Yes, it is easy enough to add the semi-colon but when using the package on auto-generated styles it isn't always possible.

I found a work-around by simply replacing the closing } with ;} to make sure the last rule is always terminated but this is kind of ugly.

iconifyit avatar Nov 06 '19 05:11 iconifyit