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

Some CSS selectors broken during CSS compression #2517

Closed
strawhatgami opened this issue Oct 1, 2018 · 7 comments · Fixed by #2670
Closed

Some CSS selectors broken during CSS compression #2517

strawhatgami opened this issue Oct 1, 2018 · 7 comments · Fixed by #2670

Comments

@strawhatgami
Copy link

The following CSS rule [style="width: 60%;"]{background-color:red;} added in conf/userstyle.css is transformed into [style="width:60%;"]{background-color:red;} (without the space in the CSS selector) in the webpage's css.php file.

A temporary way to get around that is to uncheck the 'compress' option in the configuration options.

I'm on 2018-04-22a "Greebo".

@splitbrain
Copy link
Collaborator

A PR with test cases and a fix would be welcome.

@selfthinker
Copy link
Collaborator

I would say this is an extreme edge case. That kind of syntax is very uncommon and extremely brittle to begin with. I would personally never use it, although it is valid.
A fix would still be welcome, but I'm not sure if it can be fixed without sacrificing more file size than necessary. Not sure what the rule should be when spaces should be kept. Maybe when inside quotation marks?

One better way of writing that CSS (although still really dodgy and not recommended) would be

[style*="width"][style*="60%"]{background-color:red;}

But best give that element a class or find other ways to select it.

@phy25
Copy link
Collaborator

phy25 commented Nov 14, 2018

I think it should be good to ignore quotation marks only. If this is happening, CSS like font-family: "Segoe UI" should also be affected, but I haven't tested this yet. - EDIT: not this case.

BTW, a resource for guys working on this: https://stackoverflow.com/questions/17123809/parsing-css-files-using-regex (Just don't have time recently to work on this)

@Klap-in
Copy link
Collaborator

Klap-in commented Jan 10, 2019

Is this something that could be upstreamed, it isn't?

@splitbrain
Copy link
Collaborator

@Klap-in you mean moving the compressor out of DokuWiki into its own library? I'd like that. I'd also be open for using a different compressor if we find something matching our requirements.

@Klap-in
Copy link
Collaborator

Klap-in commented Jan 10, 2019

Hmm, I assumed that the lesserphp library performs the compression as well.
I see the compressor is actually the step after the lesserphp.

To obtain some understanding, what are the requirements?

In first random search I spotted: https://github.com/matthiasmullie/minify. By who @phy25 is already inspired for the current solution.

@phy25
Copy link
Collaborator

phy25 commented Jan 10, 2019

I wonder "short comment for browser hacks" is still useful in this Chrome age. Also tests are important, too.

Maybe we can open another issue for the compressor library selection, since I will soon open the PR for a (temporary) fix.

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

Successfully merging a pull request may close this issue.

5 participants