Expected semi-colon or close brace, found

Nov 2, 2011 at 8:04 PM

I am receiving the following errors with css files:

       Expected semi-colon or close brace, found '!' for: 

       A IE7 hack vertical-align: -2px !ie;




       Expected semi-colon or close brace, found '.' for:

           .margin-bottom:-3px;<-- error here


Nov 2, 2011 at 8:16 PM

Goodness. Both of those examples are malformed CSS, at least as far as the language syntax is concerned -- that's why the errors are happening. An "!ie" token doesn't fit the grammar, and property names can't start with periods. Why should those two syntax issues not produce syntax errors? Can you point me to documentation pages out there on the web that show that those are valid CSS constructs? If so, I'll change the parser/scanner to allow for them.

Nov 2, 2011 at 8:23 PM

They are both from 3rd party css, so I will check with those developers. Thanks for your time.

Nov 2, 2011 at 8:24 PM

I found a page that talks about the !ie hack: http://www.webdevout.net/css-hacks#unrecommended-important_ie

Still looking for the period-prefixed property name (unless it is just the same concept as _ and - prefixes, but with a different non-alphanumeric character.

Nov 2, 2011 at 8:37 PM

I'm not sure I really want to allow either of those syntax elements all the time, though, since that documentation page clearly says these hacks produce invalid CSS syntax. That's the reason AjaxMin throws the error: it's invalid CSS syntax. It does look like the tool still creates the proper output from the invalid input, though; so if you just want to get rid of the errors in your build, you can just exclude the CSS1027 error from the command-line (although that would mean it wouldn't throw the error for any actual issues that may occur, either).

I think I really need to step back and come up with a better way of handling "invalid" CSS in general, though, since that's a very common occurrence. The language specs say that if a client encounters invalid syntax, it should just ignore that part and move on to the next. Ideally what I'd like to do is to enable the developer to annotate a rule that he knows will be invalid so that AjaxMin won't throw an error for it -- because the error is expected. That could be useful.

Nov 2, 2011 at 8:44 PM

Or maybe I should just add another command-line parameter for "stupid-IE hacks" that, if specified, would allow for the fun little hacks that are listed on that page. There are some good ones listed there ("good" being in the painful sort of way).

Nov 2, 2011 at 8:57 PM

This page talks about the period-prefixed http://www.coding4streetcred.com/blog/post/CSS-Cross-Browser-Hacks.aspx

Thanks for your responses.

Nov 3, 2011 at 2:20 PM

I was able to change the period-prefix to an asterisk-prefix and that issue is taken care of. However my hands are tied on the !IE issue and it is unfortunately required. So support for it would be wonderful but I understand if you to choose not to since it is invalid css.



Nov 4, 2011 at 1:17 AM

Okay, I added support for some more invalid-CSS IE hacks (apparently I was already special-handling the *property hack), including the .property and !ie ones you asked for. Released in version 4.34.

Nov 4, 2011 at 2:47 PM

Works perfect. Thanks!