Skip to content
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

Doesn't like commented out CSS #252

Closed
popovichN opened this issue Jan 17, 2017 · 5 comments
Closed

Doesn't like commented out CSS #252

popovichN opened this issue Jan 17, 2017 · 5 comments
Labels

Comments

@popovichN
Copy link

popovichN commented Jan 17, 2017

It appears that commented out CSS causes problems ...

I.e.

/* table {
}*/

td {
	font-size: 14px;
	font-family: Arial;
}

The Arial/14px doesn't work unless I delete the table class.

@Rich-Harris
Copy link
Member

Oh, interesting. Reproduced in the REPL here — looks like the comment delimiters are being mistaken for part of the selector, and being erroneously duplicated:

screen shot 2017-01-17 at 9 25 52 am

Not hugely surprising, since the CSS transformer is just a big mess of regexes. Relevant XKCD:

mc2ws

Might be time to start investigating implementing a proper CSS parser, as per #245 (comment) discussion. In the meantime, workarounds are a) removing comments, or b) putting them on a single line.

@evs-chris
Copy link
Contributor

A proper CSS parser would be ideal. For a quick fix though, here's where the regex wizard addressed the same issue when it arose in Ractive: https://github.com/ractivejs/ractive/pull/2684/files. It looks like it would be a super simple patch.

@Rich-Harris
Copy link
Member

Of course! I should have known @MartinKolarik would have fixed this already — the finest regex warrior I ever rode into battle with. Preparing a PR now — thanks @evs-chris

Rich-Harris added a commit that referenced this issue Jan 17, 2017
handle multiline comments in CSS
@Rich-Harris
Copy link
Member

fixed in 1.6.4, thanks everyone

@MartinKolarik
Copy link

Oh yeah, regular expressions are fun 😆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants