-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error when "css \9 hack " #21
Comments
What is the error? And what do you think it should do? |
var parserlib = require("parserlib");//npm install -g parserlib
var parser = new parserlib.css.Parser({
starHack : true,
underscoreHack : true,
ieFilters: true,
strict : false
});
parser.addListener("error", function(event){
console.log("Parse error: " + event.message + " (" + event.line + "," + event.col + ")", "error");
console.error('\033[91m' + event.message + event.line + "," + event.col+ '\033[0m');
console.log(event);
});
var css = '.W_input{padding:0 0 0 2px; padding:4px 0 0 2px\9;vertical-align:top; color:#666;}';
//css = css2.replace(/\\9/g,'');
var ast = parser.parse(css);
//-------------------------------------------------------------------------------//
//node test-css-parserlib.js Parse error: Expected RBRACE at line 1, col 45. (1,45) error |
I think you can support another hack option paramter for the Parser constructor. |
@nzakas I'm curious what you think with regard to support for tolerating all the browser hacks. I'm torn between asking for support versus keeping the parser true to the CSS spec. Here's a list from Paul Irish: I was thinking of suggesting to consolide tolerance for all hacks into one option (either consider browser hacks a syntax error, or tolerate them) and make the presence of a hack fire a new event for handling downstream. Something like that would be useful for CSSLint. However, I can also see how it complicates the parser. Though these hacks seem to have longevity once introduced, it seems like a bit of a chore to have to update the parser logic based on a browser release instead of a CSS spec update. |
Generally I think it's good to be tolerant of hacks that browsers are tolerant of. I've gone with the convention of one option per hack, but right now just have star and underscore hacks. \9 seems like a good one to add as well, but I'm unsure of some of the others. |
If they're using inline CSS hacks for IE, they're doing it wrong. They should be using conditional comments to serve a separate stylesheet that gets ignored by other browsers but gets parsed by IE all the way back to IE5. |
The \9 trick isn't just for old IE, it is useful for IE9 (not sure about 10) after you have already done you separate sheets for IE9< |
is this issue be fixed? |
No |
I think we should add /9 to the list of allowed hacks. That said, it is a bit complicated because I believe you can put anything after the /, not just a 9. However, maybe we should consider only allowing /9 rather than trying to accommodate the entire spectrum. |
I suspect the latest round of escaping hacks actually makes this "work" -- that is, the I think something like |
Just for completion, these error seems still to be around, at least on current beta branch:
I will remove the \9 hack soon anyway ..., but its still reported though. |
The text was updated successfully, but these errors were encountered: