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

negation-pseudo-class-bug & fix suggestion #5

Open
HIGGO36 opened this issue Oct 26, 2019 · 1 comment
Open

negation-pseudo-class-bug & fix suggestion #5

HIGGO36 opened this issue Oct 26, 2019 · 1 comment

Comments

@HIGGO36
Copy link

HIGGO36 commented Oct 26, 2019

While using your tool to unminify a min.css file, I noticed some errors that were created in the final deminified file, which all dealt with the "negation pseudo-class".

So, I found the issue within the 'cssunminifier.js' file located in the /lib/ folder.

My suggested fix: (Look at the code around line 24, .replace(/\n ([^:]+):\s*/g, **'\n $1:')** )
// I removed the additional unnecessary spaces

Your current one has: .replace(/\n ([^:]+):\s*/g, '\n $1: ')

Beginning around line 17 of ' cssunminifier/lib/cssunminifier.js ' file:

Replace current code with:

code = code
        .split('\t').join('    ')
        .replace(/\s*{\s*/g, ' {\n    ')
        .replace(/;\s*/g, ';\n    ')
        .replace(/,\s*/g, ', ')
        .replace(/[ ]*}\s*/g, '}\n')
        .replace(/\}\s*(.+)/g, '}\n$1')
        .replace(/\n    ([^:]+):\s*/g, '\n $1:')
        .replace(/([A-z0-9\)])}/g, '$1;\n}');

  if (tab != 4) {
	    for (;tab != 0;tab--) { space += ' '; }
	    code = code.replace(/\n    /g, '\n'+space);
    } 

If it helps, here is some code that will produce errors without the suggested fixes from above.

#lione{font-size:2em;color:#4682b4}#first{font-size:1em;color:red}#linext{font-size:2em;color:#000}#next{font-size:1em;color:orange}#lithird{font-size:2em;color:#00f}#third{font-size:1em;color:pink}#lilast{font-size:2em;color:brown}#one{font-size:1em;color:green}@media screen and (max-width:768px){.level-item:not(:last-child){margin-bottom:.75rem}}@media print,screen and (min-width:769px){.level-left .level-item:not(:last-child),.level-right .level-item:not(:last-child){margin-right:.75rem}}@media print,screen and (min-width:769px){.columns:not(.is-desktop){display:flex}}@media print,screen and (min-width:769px){.tile:not(.is-child){display:flex}.tile.is-1{flex:none;width:8.3333333333%}.tile.is-2{flex:none;width:16.6666666667%}.tile.is-3{flex:none;width:25%}.tile.is-4{flex:none;width:33.3333333333%}.tile.is-5{flex:none;width:41.6666666667%}.tile.is-6{flex:none;width:50%}.tile.is-7{flex:none;width:58.3333333333%}.tile.is-8{flex:none;width:66.6666666667%}.tile.is-9{flex:none;width:75%}.tile.is-10{flex:none;width:83.3333333333%}.tile.is-11{flex:none;width:91.6666666667%}.tile.is-12{flex:none;width:100%}}

@HIGGO36
Copy link
Author

HIGGO36 commented Oct 26, 2019

Also, can see the repo I setup to support this project, which had my suggested updates added.

https://github.com/HIGGO36/cssunminifier-higgo36

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

No branches or pull requests

1 participant