Skip to content

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

Description

@HIGGO36

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%}}

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions