Skip to content

Commit

Permalink
Fix for css minification of #feedback is not a color
Browse files Browse the repository at this point in the history
  • Loading branch information
Brad Robinson committed Apr 27, 2011
1 parent dc11ed2 commit 3f2c25e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions MiniME/CssMin.cs
Expand Up @@ -107,15 +107,15 @@ public string Minify(string input, int MaxLineLength)
);

// normalize #aBc to #ABC. These will be in groups of either 3 or 6
input = Regex(@"#([a-fA-F0-9]{3}){1,2}").Replace(input, m => m.Value.ToUpperInvariant());
input = Regex(@"#([a-fA-F0-9]{3}){1,2}\b").Replace(input, m => m.Value.ToUpperInvariant());

// Shorten colors from #AABBCC to #ABC. Note that we want to make sure
// the color is not preceded by either ", " or =. Indeed, the property
// filter: chroma(color="#FFFFFF");
// would become
// filter: chroma(color="#FFF");
// which makes the filter break in IE.
input = Regex(@"([^""'=\s])(\s*)#([0-9A-F])\3([0-9A-F])\4([0-9A-F])\5").Replace(input, "$1$2#$3$4$5");
input = Regex(@"([^""'=\s])(\s*)#([0-9A-F])\3([0-9A-F])\4([0-9A-F])\5\b").Replace(input, "$1$2#$3$4$5");

// Replace multiple semi-colons in a row by a single one
// See SF bug #1980989
Expand Down
7 changes: 6 additions & 1 deletion MiniMETestCases/TestScripts/css_colors.txt
Expand Up @@ -12,6 +12,11 @@ div
color:#11aaff;
}

div#feedback
{
color:#feedba;
}

-----
div{color:#6496C8;color:#ABCDEF;color:#1AF}
div{color:#6496C8;color:#ABCDEF;color:#1AF}div#feedback{color:#FEEDBA}
-----

0 comments on commit 3f2c25e

Please sign in to comment.