Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

  • Loading branch information...
commit 4c54e62890bc61d72122be044fd8c1e6fa83912b 1 parent d7953d5
@reid reid authored
View
9 src/com/yahoo/platform/yui/compressor/CssCompressor.java
@@ -240,12 +240,17 @@ public void compress(Writer out, int linebreakpos)
m = p.matcher(css);
sb = new StringBuffer();
while (m.find()) {
- // Test for AABBCC pattern
- if (m.group(3).equalsIgnoreCase(m.group(4)) &&
+ if (m.group(1).equals("}")) {
+ // Likely an ID selector. Don't touch.
+ // #AABBCC is a valid ID. IDs are case-sensitive.
+ m.appendReplacement(sb, m.group());
+ } else if (m.group(3).equalsIgnoreCase(m.group(4)) &&
m.group(5).equalsIgnoreCase(m.group(6)) &&
m.group(7).equalsIgnoreCase(m.group(8))) {
+ // #AABBCC pattern
m.appendReplacement(sb, (m.group(1) + m.group(2) + "#" + m.group(3) + m.group(5) + m.group(7)).toLowerCase());
} else {
+ // Any other color.
m.appendReplacement(sb, m.group().toLowerCase());
}
}
View
12 tests/preserve-case.css
@@ -0,0 +1,12 @@
+#AddAddressForm {
+ padding: 0;
+}
+#AddAddressForm .messageBoxNeutral {
+ padding: 0;
+}
+#FeedbackMailForm{
+ padding: 0;
+}
+#FeedbackMailForm .classe{
+ margin: 0;
+}
View
1  tests/preserve-case.css.min
@@ -0,0 +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.