Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed border-color:#ABCDEF #AABBCC #ABCDEF #AABBCC use case, which wa…

…s broken after the more rebost ID fix was added
  • Loading branch information...
commit 91c5ea5ba37d8f969c3939e3b33a1296c561b872 1 parent cb68d77
@sdesai sdesai authored
View
5 build.xml
@@ -20,7 +20,8 @@
includes="**/*.java"
deprecation="off"
debug="on"
- source="1.4">
+ target="1.5"
+ source="1.5">
<classpath>
<pathelement location="${lib.dir}/jargs-1.0.jar"/>
<pathelement location="${lib.dir}/rhino-1.6R7.jar"/>
@@ -63,4 +64,4 @@
includes="${dist.package.name}/**/*"/>
</target>
-</project>
+</project>
View
BIN  build/yuicompressor-2.4.7.jar
Binary file not shown
View
33 ports/js/cssmin.js
@@ -107,7 +107,7 @@ YAHOO.compressor._extractDataUrls = function (css, preservedTokens) {
*
* DOES NOT compress IE filters, which have hex color values (which would break things).
* e.g. filter: chroma(color="#FFFFFF");
- *
+ *
* DOES NOT compress invalid hex values.
* e.g. background-color: #aabbccdd
*
@@ -119,28 +119,35 @@ YAHOO.compressor._extractDataUrls = function (css, preservedTokens) {
YAHOO.compressor._compressHexColors = function(css) {
// Look for hex colors inside { ... } (to avoid IDs) and which don't have a =, or a " in front of them (to avoid filters)
- var pattern = /([^"'=\s])(\s*)#([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])(\}|[^0-9a-f{][^{]*?\})/gi,
+ var pattern = /(\=\s*?["']?)?#([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])(\}|[^0-9a-f{][^{]*?\})/gi,
m,
index = 0,
+ isFilter,
sb = [];
while ((m = pattern.exec(css)) !== null) {
- if (m[3].toLowerCase() == m[4].toLowerCase() &&
- m[5].toLowerCase() == m[6].toLowerCase() &&
- m[7].toLowerCase() == m[8].toLowerCase()) {
+ sb.push(css.substring(index, m.index));
- // Enough searching, start moving stuff over to the buffer
- sb.push(css.substring(index, m.index));
- sb.push((m[1] + m[2] + "#" + m[3] + m[5] + m[7]).toLowerCase());
+ isFilter = m[1];
- index = pattern.lastIndex = pattern.lastIndex - m[9].length;
+ if (isFilter) {
+ // Restore, maintain case, otherwise filter will break
+ sb.push(m[1] + "#" + (m[2] + m[3] + m[4] + m[5] + m[6] + m[7]));
} else {
- sb.push(css.substring(index, m.index));
- sb.push((m[1] + m[2] + "#" + m[3] + m[4] + m[5] + m[6] + m[7] + m[8]).toLowerCase());
-
- index = pattern.lastIndex = pattern.lastIndex - m[9].length;
+ if (m[2].toLowerCase() == m[3].toLowerCase() &&
+ m[4].toLowerCase() == m[5].toLowerCase() &&
+ m[6].toLowerCase() == m[7].toLowerCase()) {
+
+ // Compress.
+ sb.push("#" + (m[3] + m[5] + m[7]).toLowerCase());
+ } else {
+ // Non compressible color, restore but lower case.
+ sb.push("#" + (m[2] + m[3] + m[4] + m[5] + m[6] + m[7]).toLowerCase());
+ }
}
+
+ index = pattern.lastIndex = pattern.lastIndex - m[8].length;
}
sb.push(css.substring(index));
View
40 src/com/yahoo/platform/yui/compressor/CssCompressor.java
@@ -292,25 +292,39 @@ public void compress(Writer out, int linebreakpos)
// which makes the filter break in IE.
// We also want to make sure we're only compressing #AABBCC patterns inside { }, not id selectors ( #FAABAC {} )
// We also want to avoid compressing invalid values (e.g. #AABBCCD to #ABCD)
- p = Pattern.compile("([^\"'=\\s])" + "(\\s*)" + "#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])" + "(:?\\}|[^0-9a-fA-F{][^{]*?\\})");
+ p = Pattern.compile("(\\=\\s*?[\"']?)?" + "#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])" + "(:?\\}|[^0-9a-fA-F{][^{]*?\\})");
+
m = p.matcher(css);
sb = new StringBuffer();
int index = 0;
+
while (m.find(index)) {
- if (m.group(3).equalsIgnoreCase(m.group(4)) &&
- m.group(5).equalsIgnoreCase(m.group(6)) &&
- m.group(7).equalsIgnoreCase(m.group(8))) {
- // #AABBCC pattern
- sb.append(css.substring(index, m.start(1)));
- sb.append((m.group(1) + m.group(2) + "#" + m.group(3) + m.group(5) + m.group(7)).toLowerCase());
- index = m.end(8);
- } else {
- // Any other color.
- sb.append(css.substring(index, m.start(1)));
- sb.append((m.group(1) + m.group(2) + "#" + m.group(3) + m.group(4) + m.group(5) + m.group(6) + m.group(7) + m.group(8)).toLowerCase());
- index = m.end(8);
+
+ sb.append(css.substring(index, m.start()));
+
+ boolean isFilter = (m.group(1) != null && !"".equals(m.group(1)));
+
+ if (isFilter) {
+ // Restore, as is. Compression will break filters
+ sb.append(m.group(1) + "#" + m.group(2) + m.group(3) + m.group(4) + m.group(5) + m.group(6) + m.group(7));
+ } else {
+ if( m.group(2).equalsIgnoreCase(m.group(3)) &&
+ m.group(4).equalsIgnoreCase(m.group(5)) &&
+ m.group(6).equalsIgnoreCase(m.group(7))) {
+
+ // #AABBCC pattern
+ sb.append("#" + (m.group(3) + m.group(5) + m.group(7)).toLowerCase());
+
+ } else {
+
+ // Non-compressible color, restore, but lower case.
+ sb.append("#" + (m.group(2) + m.group(3) + m.group(4) + m.group(5) + m.group(6) + m.group(7)).toLowerCase());
+ }
}
+
+ index = m.end(7);
}
+
sb.append(css.substring(index));
css = sb.toString();
View
8 tests/color-simple.css
@@ -0,0 +1,8 @@
+.foo, #AABBCC {
+ background-color:#aabbcc;
+ border-color:#Ee66aA #ABCDEF #FeAb2C;
+ filter:chroma(color = #FFFFFF );
+ filter:chroma(color="#AABBCC");
+ filter:chroma(color='#BBDDEE');
+ color:#112233
+}
View
1  tests/color-simple.css.min
@@ -0,0 +1 @@
+.foo,#AABBCC{background-color:#abc;border-color:#e6a #abcdef #feab2c;filter:chroma(color = #FFFFFF);filter:chroma(color="#AABBCC");filter:chroma(color='#BBDDEE');color:#123}
View
10 tests/color.css
@@ -1,7 +1,7 @@
.color {
me: rgb(123, 123, 123);
impressed: #FfEedD;
- again: #456789;
+ again: #ABCDEF;
andagain:#aa66cc;
background-color:#aa66ccc;
filter: chroma(color="#FFFFFF");
@@ -12,24 +12,28 @@
#AABBCC {
background-color:#ffee11;
- filter: chroma(color="#FFFFFF");
+ filter: chroma(color = #FFFFFF );
color:#441122;
+ foo:#00fF11 #ABC #AABbCc #123344;
border-color:#aa66ccC
}
.foo #AABBCC {
background-color:#fFEe11;
color:#441122;
- filter: chroma(color="#FFFFFF")
+ border-color:#AbC;
+ filter: chroma(color= #FFFFFF)
}
.bar, #AABBCC {
background-color:#FFee11;
+ border-color:#00fF11 #ABCDEF;
color:#441122;
}
.foo, #AABBCC.foobar {
background-color:#ffee11;
+ border-color:#00fF11 #ABCDEF #AABbCc;
color:#441122;
}
View
4 tests/color.css.min
@@ -1,3 +1 @@
-.color{me:#7b7b7b;impressed:#fed;again:#456789;andagain:#a6c;background-color:#aa66ccc;filter:chroma(color="#FFFFFF");background:none repeat scroll 0 0 #f00;alpha:rgba(1,2,3,4);color:#12a}#AABBCC{background-color:#fe1;filter:chroma(color="#FFFFFF");color:#412;border-color:#aa66ccC}.foo #AABBCC{background-color:#fe1;color:#412;filter:chroma(color="#FFFFFF")}.bar,#AABBCC{background-color:#fe1;color:#412}.foo,#AABBCC.foobar{background-color:#fe1;color:#412}@media screen{.bar,#AABBCC{background-color:#fe1;color:#412}}
-
-
+.color{me:#7b7b7b;impressed:#fed;again:#abcdef;andagain:#a6c;background-color:#aa66ccc;filter:chroma(color="#FFFFFF");background:none repeat scroll 0 0 #f00;alpha:rgba(1,2,3,4);color:#12a}#AABBCC{background-color:#fe1;filter:chroma(color = #FFFFFF);color:#412;foo:#0f1 #ABC #abc #123344;border-color:#aa66ccC}.foo #AABBCC{background-color:#fe1;color:#412;border-color:#AbC;filter:chroma(color= #FFFFFF)}.bar,#AABBCC{background-color:#fe1;border-color:#0f1 #abcdef;color:#412}.foo,#AABBCC.foobar{background-color:#fe1;border-color:#0f1 #abcdef #abc;color:#412}@media screen{.bar,#AABBCC{background-color:#fe1;color:#412}}
Please sign in to comment.
Something went wrong with that request. Please try again.