Permalink
Browse files

Fixing emission of compressed media queries.

  • Loading branch information...
1 parent d2e52a0 commit 4c0d1b83e3453210d01d134150bf0a89f43952e5 Aaron Leung committed Dec 12, 2012
Showing with 12 additions and 6 deletions.
  1. +1 −1 node.hpp
  2. +11 −5 node_emitters.cpp
View
@@ -243,7 +243,7 @@ namespace Sass {
bool operator>(Node rhs) const;
bool operator>=(Node rhs) const;
- string to_string(Type inside_of = none, const string space = " ") const;
+ string to_string(Type inside_of = none, const string space = " ", const bool in_media_feature = false) const;
void emit_nested_css(stringstream& buf, size_t depth, bool at_toplevel = false, bool in_media_query = false, bool source_comments = false);
void emit_propset(stringstream& buf, size_t depth, const string& prefix, const bool compressed = false);
void echo(stringstream& buf, size_t depth = 0);
View
@@ -15,7 +15,7 @@ using std::endl;
namespace Sass {
- string Node::to_string(Type inside_of, const string space) const
+ string Node::to_string(Type inside_of, const string space, const bool in_media_feature) const
{
if (is_null()) return "";
switch (type())
@@ -39,22 +39,27 @@ namespace Sass {
string result;
if (at(0).type() == rule) {
result += "(";
- result += at(0).to_string(none, space);
+ result += at(0).to_string(none, space, true);
result += ")";
}
else {
- result += at(0).to_string(none, space);
+ string tmp = at(0).to_string(none, space);
+ result += tmp;
+ if (tmp == "and" && space == "") result += " ";
}
for (size_t i = 1, S = size(); i < S; ++i) {
if (at(i).type() == rule) {
result += space;
result += "(";
- result += at(i).to_string(none, space);
+ result += at(i).to_string(none, space, true);
result += ")";
}
else {
result += " ";
- result += at(i).to_string(none, space);
+ // result += at(i).to_string(none, space);
+ string tmp = at(i).to_string(none, space);
+ result += tmp;
+ if (tmp == "and" && space == "") result += " ";
}
}
return result;
@@ -125,6 +130,7 @@ namespace Sass {
string result(at(0).to_string(property, space));
result += ":";
result += space;
+ if (space == "" && in_media_feature) result += " ";
result += at(1).to_string(none, space);
return result;
} break;

0 comments on commit 4c0d1b8

Please sign in to comment.