stoyan / cssshrink

CSS minifier
1.05k stars 81 forks source link

Invalid font-family gets TypeError #15

Open dy opened 10 years ago

dy commented 10 years ago

I have wrong font-family value: font-family:13px, and cssshrink CLI gets:

/usr/local/lib/node_modules/cssshrink/lib/visitors/font-family-generic.js:28
      var value = node[2][i][1].toLowerCase();
                                ^
TypeError: Object number,13 has no method 'toLowerCase'
    at Object.module.exports.process (/usr/local/lib/node_modules/cssshrink/lib/visitors/font-family-generic.js:28:33)
    at tree (/usr/local/lib/node_modules/cssshrink/node_modules/gonzales-ast/lib/traverse.js:7:20)
    at tree (/usr/local/lib/node_modules/cssshrink/node_modules/gonzales-ast/lib/traverse.js:15:13)
    at tree (/usr/local/lib/node_modules/cssshrink/node_modules/gonzales-ast/lib/traverse.js:15:13)
    at tree (/usr/local/lib/node_modules/cssshrink/node_modules/gonzales-ast/lib/traverse.js:15:13)
    at /usr/local/lib/node_modules/cssshrink/node_modules/gonzales-ast/lib/traverse.js:24:11
    at Array.forEach (native)
    at Object.traverse (/usr/local/lib/node_modules/cssshrink/node_modules/gonzales-ast/lib/traverse.js:23:12)
    at traverseAST (/usr/local/lib/node_modules/cssshrink/lib/shrink.js:50:15)
    at Object.shrink (/usr/local/lib/node_modules/cssshrink/lib/shrink.js:66:9)

It took a while to find out that CSS was invalid. It would be great to log a bit more humanized error messages.

gijsroge commented 10 years ago

Hehe, just had this error aswel, searched 20 minutes for it. Indeed, a more humanized error would be nice :D