Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Don't transform CSS ID selectors. Fix #2528102.

  • Loading branch information...
commit 4c54e62890bc61d72122be044fd8c1e6fa83912b 1 parent d7953d5
Reid Burke reid authored
9 src/com/yahoo/platform/yui/compressor/CssCompressor.java
@@ -240,12 +240,17 @@ public void compress(Writer out, int linebreakpos)
240 240 m = p.matcher(css);
241 241 sb = new StringBuffer();
242 242 while (m.find()) {
243   - // Test for AABBCC pattern
244   - if (m.group(3).equalsIgnoreCase(m.group(4)) &&
  243 + if (m.group(1).equals("}")) {
  244 + // Likely an ID selector. Don't touch.
  245 + // #AABBCC is a valid ID. IDs are case-sensitive.
  246 + m.appendReplacement(sb, m.group());
  247 + } else if (m.group(3).equalsIgnoreCase(m.group(4)) &&
245 248 m.group(5).equalsIgnoreCase(m.group(6)) &&
246 249 m.group(7).equalsIgnoreCase(m.group(8))) {
  250 + // #AABBCC pattern
247 251 m.appendReplacement(sb, (m.group(1) + m.group(2) + "#" + m.group(3) + m.group(5) + m.group(7)).toLowerCase());
248 252 } else {
  253 + // Any other color.
249 254 m.appendReplacement(sb, m.group().toLowerCase());
250 255 }
251 256 }
12 tests/preserve-case.css
... ... @@ -0,0 +1,12 @@
  1 +#AddAddressForm {
  2 + padding: 0;
  3 +}
  4 +#AddAddressForm .messageBoxNeutral {
  5 + padding: 0;
  6 +}
  7 +#FeedbackMailForm{
  8 + padding: 0;
  9 +}
  10 +#FeedbackMailForm .classe{
  11 + margin: 0;
  12 +}
1  tests/preserve-case.css.min
... ... @@ -0,0 +1 @@
  1 +#AddAddressForm{padding:0}#AddAddressForm .messageBoxNeutral{padding:0}#FeedbackMailForm{padding:0}#FeedbackMailForm .classe{margin:0}

0 comments on commit 4c54e62

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