buntarb / closure-stylesheets

Automatically exported from code.google.com/p/closure-stylesheets
Apache License 2.0
0 stars 0 forks source link

pretty-print flag wrongly adds spaces between multiple negation pseudo-classes (:not) #37

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a test.css file:

    em:not(.a):not(.b) {
      color: red;
    }

2. Create a pretty-printed file with:
    $ java -jarclosure-stylesheets.jar --pretty-print --output-file ./test.p.css test.css

3. Check its contents:

    $ cat test.p.css 
    em:not(.a) :not(.b)  {
      color: red;
    }

This is wrong, because the space added between both :not pseudo-classes changes 
the meaning of this selector. The desired 'em' element will not be selected.

What is the expected output? What do you see instead?

The correct output is produced without the pretty-print flag:

    $ java -jar tools/closure-stylesheets.jar --output-file ./test.c.css test.css
    $ cat test.c.css 
    em:not(.a):not(.b){color:red}

What version of the product are you using? On what operating system?

Revision: 86bb800d79a3
Chrome 27.0.1453.116

Please provide any additional information below.

The following change seems to fix this issue (unsure if this is the right fix 
though).

$ git diff
diff --git a/src/com/google/common/css/compiler/passes/PrettyPrinter.java 
b/src/com/google/common/css/compiler/passes/PrettyPrinter.java
index 8a37b7c..9da9ab7 100644
--- a/src/com/google/common/css/compiler/passes/PrettyPrinter.java
+++ b/src/com/google/common/css/compiler/passes/PrettyPrinter.java
@@ -347,7 +347,7 @@ public class PrettyPrinter extends DefaultTreeVisitor
   public void leavePseudoClass(CssPseudoClassNode node) {
     if (node.getFunctionType() == FunctionType.NOT) {
       deleteEndingIfEndingIs(", ");
-      sb.append(") ");
+      sb.append(")");
     }
   }

Original issue reported on code.google.com by alo.and on 4 Jul 2013 at 9:51