Skip to content

Commit a1c719f

Browse files
author
Richard Hulse
committed
Update YUI CSS tests and fix failures
This is for the ruby port of YUI CSS compressor only
1 parent 60f2944 commit a1c719f

14 files changed

+24
-15
lines changed

lib/modules/yui_compressor.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def compress(css, line_length=0)
5555
css.gsub!(/:(?:0 )+0(;|\})/, ':0\1')
5656

5757
# Restore background-position:0 0; if required
58-
css.gsub!(/background-position:0(;|\})/i, 'background-position:0 0\1')
58+
css.gsub!(/(background-position|transform-origin|webkit-transform-origin|moz-transform-origin|o-transform-origin|ms-transform-origin):0(;|\})/i){ "#{$1.downcase}:0 0#{$2}" }
5959

6060
# Replace 0.6 with .6, but only when preceded by : or a space.
6161
css.gsub!(/(:|\s)0+\.(\d+)/, '\1.\2')
@@ -74,6 +74,9 @@ def compress(css, line_length=0)
7474
# which makes the filter break in IE.
7575
css.gsub!(/([^"'=\s])(\s?)\s*#([0-9a-f])\3([0-9a-f])\4([0-9a-f])\5/i, '\1\2#\3\4\5')
7676

77+
# border: none -> border:0
78+
css.gsub!(/(border|border-top|border-right|border-bottom|border-right|outline|background):none(;|\})/i){ "#{$1.downcase}:0#{$2}" }
79+
7780
# shorter opacity IE filter
7881
css.gsub!(/progid:DXImageTransform\.Microsoft\.Alpha\(Opacity=/i, "alpha(opacity=")
7982

test/yui_compressor_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def test_line_length_split_at_50
5252
body{background:#F5F1DA;font:small Verdana,Helvetica,Arial,sans-serif;color:#310C04;}
5353
#pw{position:relative;width:960px;text-align:left;}
5454
CSS
55-
expected_css = %Q(*{font-size:100%;margin:0;padding:0}img{border:none}\n#cont-pri img,.arc #cont-sec img,embed{border:1px solid #000}\nbody{background:#F5F1DA;font:small Verdana,Helvetica,Arial,sans-serif;color:#310C04}\n#pw{position:relative;width:960px;text-align:left})
55+
expected_css = %Q(*{font-size:100%;margin:0;padding:0}img{border:0}#cont-pri img,.arc #cont-sec img,embed{border:1px solid #000}\nbody{background:#F5F1DA;font:small Verdana,Helvetica,Arial,sans-serif;color:#310C04}\n#pw{position:relative;width:960px;text-align:left})
5656
assert_equal(expected_css, @yui.compress(test_css,50))
5757
end
5858

@@ -64,7 +64,7 @@ def test_line_length_split_at_100
6464
body{background:#F5F1DA;font:small Verdana,Helvetica,Arial,sans-serif;color:#310C04;}
6565
#pw{position:relative;width:960px;text-align:left;}
6666
CSS
67-
expected_css = %Q(*{font-size:100%;margin:0;padding:0}img{border:none}#cont-pri img,.arc #cont-sec img,embed{border:1px solid #000}\nbody{background:#F5F1DA;font:small Verdana,Helvetica,Arial,sans-serif;color:#310C04}#pw{position:relative;width:960px;text-align:left})
67+
expected_css = %Q(*{font-size:100%;margin:0;padding:0}img{border:0}#cont-pri img,.arc #cont-sec img,embed{border:1px solid #000}\nbody{background:#F5F1DA;font:small Verdana,Helvetica,Arial,sans-serif;color:#310C04}#pw{position:relative;width:960px;text-align:left})
6868
assert_equal(expected_css, @yui.compress(test_css,100))
6969
end
7070

@@ -76,7 +76,7 @@ def test_line_length_split_at_300
7676
body{background:#F5F1DA;font:small Verdana,Helvetica,Arial,sans-serif;color:#310C04;}
7777
#pw{position:relative;width:960px;text-align:left;}
7878
CSS
79-
expected_css = %Q(*{font-size:100%;margin:0;padding:0}img{border:none}#cont-pri img,.arc #cont-sec img,embed{border:1px solid #000}body{background:#F5F1DA;font:small Verdana,Helvetica,Arial,sans-serif;color:#310C04}#pw{position:relative;width:960px;text-align:left})
79+
expected_css = %Q(*{font-size:100%;margin:0;padding:0}img{border:0}#cont-pri img,.arc #cont-sec img,embed{border:1px solid #000}body{background:#F5F1DA;font:small Verdana,Helvetica,Arial,sans-serif;color:#310C04}#pw{position:relative;width:960px;text-align:left})
8080
assert_equal(expected_css, @yui.compress(test_css,300))
8181
end
8282

test/yuicss/border-none.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
a {
2+
border: none;
3+
}
4+
b {BACKGROUND:none}
5+
s {border-top: none;}

test/yuicss/border-none.css.min

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
a{border:0}b{background:0}s{border-top:0}

test/yuicss/bug2527974.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
body {
88
yo: cats;
99
}
10+
ul[id$=foo] label:hover {yo: yo;}

test/yuicss/bug2527974.css.min

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
/*! $LastChangedRevision: 81 $ $LastChangedDate: 2009-05-27 17:41:02 +0100 (Wed, 27 May 2009) $ */body{yo:cats}
1+
/*! $LastChangedRevision: 81 $ $LastChangedDate: 2009-05-27 17:41:02 +0100 (Wed, 27 May 2009) $ */body{yo:cats}ul[id$=foo] label:hover{yo:yo}

test/yuicss/color.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
me: rgb(123, 123, 123);
33
impressed: #ffeedd;
44
filter: chroma(color="#FFFFFF");
5-
background: none repeat scroll 0 0 rgb(255, 255,0);
5+
background: none repeat scroll 0 0 rgb(255, 0,0);
66
alpha: rgba(1, 2, 3, 4);
77
}

test/yuicss/color.css.min

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
.color{me:#7b7b7b;impressed:#fed;filter:chroma(color="#FFFFFF");background:none repeat scroll 0 0 #ff0;alpha:rgba(1,2,3,4)}
1+
.color{me:#7b7b7b;impressed:#fed;filter:chroma(color="#FFFFFF");background:none repeat scroll 0 0 #f00;alpha:rgba(1,2,3,4)}

test/yuicss/media-multi.css

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
@media only all and (max-width:50em), only all and (max-device-width:800px), only all and (max-width:780px) {
2-
p{
3-
some-css : here
4-
}
2+
some-css : here
53
}

test/yuicss/media-multi.css.min

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
@media only all and (max-width:50em),only all and (max-device-width:800px),only all and (max-width:780px){p{some-css:here}}
1+
@media only all and (max-width:50em),only all and (max-device-width:800px),only all and (max-width:780px){some-css:here}

0 commit comments

Comments
 (0)