Skip to content
This repository
Browse code

Fixing emission of compressed media queries.

  • Loading branch information...
commit 4c0d1b83e3453210d01d134150bf0a89f43952e5 1 parent d2e52a0
Aaron Leung authored December 12, 2012
2  node.hpp
@@ -243,7 +243,7 @@ namespace Sass {
243 243
     bool operator>(Node rhs) const;
244 244
     bool operator>=(Node rhs) const;
245 245
 
246  
-    string to_string(Type inside_of = none, const string space = " ") const;
  246
+    string to_string(Type inside_of = none, const string space = " ", const bool in_media_feature = false) const;
247 247
     void emit_nested_css(stringstream& buf, size_t depth, bool at_toplevel = false, bool in_media_query = false, bool source_comments = false);
248 248
     void emit_propset(stringstream& buf, size_t depth, const string& prefix, const bool compressed = false);
249 249
     void echo(stringstream& buf, size_t depth = 0);
16  node_emitters.cpp
@@ -15,7 +15,7 @@ using std::endl;
15 15
 
16 16
 namespace Sass {
17 17
 
18  
-  string Node::to_string(Type inside_of, const string space) const
  18
+  string Node::to_string(Type inside_of, const string space, const bool in_media_feature) const
19 19
   {
20 20
     if (is_null()) return "";
21 21
     switch (type())
@@ -39,22 +39,27 @@ namespace Sass {
39 39
         string result;
40 40
         if (at(0).type() == rule) {
41 41
           result += "(";
42  
-          result += at(0).to_string(none, space);
  42
+          result += at(0).to_string(none, space, true);
43 43
           result += ")";
44 44
         }
45 45
         else {
46  
-          result += at(0).to_string(none, space);
  46
+          string tmp = at(0).to_string(none, space);
  47
+          result += tmp;
  48
+          if (tmp == "and" && space == "") result += " ";
47 49
         }
48 50
         for (size_t i = 1, S = size(); i < S; ++i) {
49 51
           if (at(i).type() == rule) {
50 52
             result += space;
51 53
             result += "(";
52  
-            result += at(i).to_string(none, space);
  54
+            result += at(i).to_string(none, space, true);
53 55
             result += ")";
54 56
           }
55 57
           else {
56 58
             result += " ";
57  
-            result += at(i).to_string(none, space);
  59
+            // result += at(i).to_string(none, space);
  60
+            string tmp = at(i).to_string(none, space);
  61
+            result += tmp;
  62
+            if (tmp == "and" && space == "") result += " ";
58 63
           }
59 64
         }
60 65
         return result;
@@ -125,6 +130,7 @@ namespace Sass {
125 130
         string result(at(0).to_string(property, space));
126 131
         result += ":";
127 132
         result += space;
  133
+        if (space == "" && in_media_feature) result += " ";
128 134
         result += at(1).to_string(none, space);
129 135
         return result;
130 136
       } break;

0 notes on commit 4c0d1b8

Please sign in to comment.
Something went wrong with that request. Please try again.