diff --git a/min/lib/Minify/CSS/Compressor.php b/min/lib/Minify/CSS/Compressor.php
index 57ccd6a..a348286 100644
--- a/min/lib/Minify/CSS/Compressor.php
+++ b/min/lib/Minify/CSS/Compressor.php
@@ -176,6 +176,7 @@ class Minify_CSS_Compressor {
*/
protected function _commentCB($m)
{
+ $hasSurroundingWs = (trim($m[0]) !== $m[1]);
$m = $m[1];
// $m is the comment content w/o the surrounding tokens,
// but the return value will replace the entire comment.
@@ -219,7 +220,11 @@ class Minify_CSS_Compressor {
$this->_inHack = false;
return '/**/';
}
- return ''; // remove all other comments
+ // Issue 107: if there's any surrounding whitespace, it may be important, so
+ // replace the comment with a single space
+ return $hasSurroundingWs // remove all other comments
+ ? ' '
+ : '';
}
/**
diff --git a/min_unit_tests/_test_files/css/comments.css b/min_unit_tests/_test_files/css/comments.css
index bb4eaed..2ef9fac 100644
--- a/min_unit_tests/_test_files/css/comments.css
+++ b/min_unit_tests/_test_files/css/comments.css
@@ -4,3 +4,6 @@
/*! YUI Compressor style comments are preserved */
/* but all other comments are removed */
+
+/* comments that have any surrounding whitespace are replaced by a single space. */
+body{ background:#fff/*eef*/ url(/path/to/image.gif) repeat-y; }
diff --git a/min_unit_tests/_test_files/css/comments.min.css b/min_unit_tests/_test_files/css/comments.min.css
index daf900f..3ea5c61 100644
--- a/min_unit_tests/_test_files/css/comments.min.css
+++ b/min_unit_tests/_test_files/css/comments.min.css
@@ -1,2 +1,3 @@
/* YUI Compressor style comments are preserved */
+body{background:#fff url(/path/to/image.gif) repeat-y}
\ No newline at end of file
diff --git a/min_unit_tests/_test_files/css/hacks.min.css b/min_unit_tests/_test_files/css/hacks.min.css
index c26cea8..68be2ee 100644
--- a/min_unit_tests/_test_files/css/hacks.min.css
+++ b/min_unit_tests/_test_files/css/hacks.min.css
@@ -1,4 +1,4 @@
-/*\*/a{}.foo{color:red}/**//*\*//*/@import "ie5mac.css";/**//*/*/.foo{display:block}/**//*/*//*/.foo{display:crazy}/**/div{width:140px;width/**/:/**/100px;width:/**/100px}html>/**/body{}div{width:400px;voice-family:"\"}\"";voice-family:inherit;width:300px}div{filter:chroma(color=#aabbcc);filter:mask(color=#000000) shadow(color=#9BAD71, direction=135) chroma(color=#000000)}@media
+/*\*/a{}.foo{color:red}/**/ /*\*//*/@import "ie5mac.css";/**/ /*/*/.foo{display:block}/**/ /*/*//*/.foo{display:crazy}/**/ div{width:140px;width/**/:/**/100px;width:/**/100px}html>/**/body{}div{width:400px;voice-family:"\"}\"";voice-family:inherit;width:300px}div{filter:chroma(color=#aabbcc);filter:mask(color=#000000) shadow(color=#9BAD71, direction=135) chroma(color=#000000)}@media
screen{/*\*/* html
div#page{height:1%}/**/}foo{_height:20px;*height:15px}@media
-tty{i{content:"\";/*" "*/}}@import 'midpassafter.css';/*"}}/* */p:first-letter {color:red}p:first-line {color:red}
\ No newline at end of file
+tty{i{content:"\";/*" "*/}}@import 'midpassafter.css';/*"}}/* */ p:first-letter {color:red}p:first-line {color:red}
\ No newline at end of file
diff --git a/min_unit_tests/_test_files/html/before.min.html b/min_unit_tests/_test_files/html/before.min.html
index 550c28a..58ba2bb 100644
--- a/min_unit_tests/_test_files/html/before.min.html
+++ b/min_unit_tests/_test_files/html/before.min.html
@@ -10,7 +10,7 @@ if(is.ua.indexOf('gecko')>=0){is.ie=is.ns=false;is.gecko=true;} =0){is.ie=is.ns=false;is.gecko=true;}