Permalink
Browse files

height:0% should not be minified to height:0

Fixes #1261
  • Loading branch information...
jmarantz committed Feb 11, 2016
1 parent 60f8018 commit 7c30b7ec44f7534f984394f710c53c6ea0e8bff8
@@ -1042,7 +1042,7 @@ TEST_F(CssFilterTest, ComplexCssTest) {
"}\n"
".foo { color: rgba(1, 2, 3, 0.4); }\n",

"body{background-image:-webkit-gradient(linear,50% 0,50% 100%,"
"body{background-image:-webkit-gradient(linear,50% 0%,50% 100%,"
"from(#e8edf0),to(#fcfcfd));color:red}.foo{color:rgba(1,2,3,.4)}" },

// Counters
@@ -356,8 +356,12 @@ bool IsLength(const GoogleString& unit) {

bool UnitsRequiredForValueZero(const GoogleString& unit) {
// https://github.com/pagespeed/mod_pagespeed/issues/1164 : Chrome does not
// allow abbreviating 0s as 0. It only allows that abbreviation for lengths.
return !IsLength(unit) && (unit != "%");
// allow abbreviating 0s or 0% as 0. It only allows that abbreviation for
// lengths.
//
// https://github.com/pagespeed/mod_pagespeed/issues/1261 See
// https://www.w3.org/TR/CSS2/visudet.html#the-height-property
return (unit == "%") || !IsLength(unit);
}

} // namespace
@@ -133,10 +133,11 @@ TEST_F(CssMinifyTest, DoNotFixBadColorsOrUnits) {
minified);
}

TEST_F(CssMinifyTest, RemoveZeroLengthButNotTimeSuffix) {
TEST_F(CssMinifyTest, RemoveZeroLengthButNotTimeOrPercentSuffix) {
const char kCss[] =
".a {\n"
" width: 0px;\n"
" height: 0%;\n"
" -moz-transition-delay: 0s, 0s;\n"
"}";
GoogleString minified;
@@ -145,7 +146,7 @@ TEST_F(CssMinifyTest, RemoveZeroLengthButNotTimeSuffix) {
EXPECT_TRUE(minify.ParseStylesheet(kCss));
// TODO(jmarantz): this CSS is not well minified. We should strip
// the spaces around the comma.
EXPECT_STREQ(".a{width:0;-moz-transition-delay:0s , 0s}", minified);
EXPECT_STREQ(".a{width:0;height:0%;-moz-transition-delay:0s , 0s}", minified);
}

} // namespace

0 comments on commit 7c30b7e

Please sign in to comment.