Skip to content

Commit

Permalink
Fixed two issues with IE 7 filters.
Browse files Browse the repository at this point in the history
* Fixed issue with multiple IE filters (IE 7 couldn't handle them if shortened).
* Fixed issue with restoring spaces in all IE filters.
  • Loading branch information
Jakub Pawlowicz committed Apr 18, 2011
1 parent c1c495b commit c7d54e1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ var CleanCSS = {
replace(/\s+/g, ' ') // multiple whitespace
replace(/ !important/g, '!important') // whitespace before !important
replace(/[ ]?,[ ]?/g, ',') // space with a comma
replace(/progid:[^(]+\(([^\)]+)/, function(match, contents) { // restore spaces inside IE filters (IE 7 issue)
replace(/progid:[^(]+\(([^\)]+)/g, function(match, contents) { // restore spaces inside IE filters (IE 7 issue)
return match.replace(/,/g, ', ');
})
replace(/ ([+~>]) /g, '$1') // replace spaces around selectors
Expand Down Expand Up @@ -99,8 +99,8 @@ var CleanCSS = {
else if (weight == 'bold') return 'font-weight:700';
else return match;
})
replace(/progid:DXImageTransform\.Microsoft\.(Alpha|Chroma)/g, function(match, contents) { // IE shorter filters
return contents.toLowerCase();
replace(/progid:DXImageTransform\.Microsoft\.(Alpha|Chroma)(\([^\)]+\))([;}'"])/g, function(match, filter, args, suffix) { // IE shorter filters but only if single (IE 7 issue)
return filter.toLowerCase() + args + suffix;
})
replace(/(\s|:)0(px|em|ex|cm|mm|in|pt|pc|%)/g, '$1' + '0') // zero + unit to zero
replace(/(border|border-top|border-right|border-bottom|border-left|outline|background):none/g, '$1:0') // none to 0
Expand Down
10 changes: 7 additions & 3 deletions test/unit-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,15 @@ vows.describe('clean-units').addBatch({
"a{filter:alpha(Opacity=80);-ms-filter:'alpha(Opacity=50)'}"
],
'short chroma': [
'progid:DXImageTransform.Microsoft.Chroma(color=#919191)', 'chroma(color=#919191)'
'a{filter:progid:DXImageTransform.Microsoft.Chroma(color=#919191)}', 'a{filter:chroma(color=#919191)}'
],
'matrix filter spaces': [
"progid:DXImageTransform.Microsoft.Matrix(M11=0.984, M22=0.984, M12=0.17, M21=-0.17, SizingMethod='auto expand')",
"progid:DXImageTransform.Microsoft.Matrix(M11=.984, M22=.984, M12=.17, M21=-.17, SizingMethod='auto expand')"
"a{filter:progid:DXImageTransform.Microsoft.Matrix(M11=0.984, M22=0.984, M12=0.17, M21=-0.17, SizingMethod='auto expand')",
"a{filter:progid:DXImageTransform.Microsoft.Matrix(M11=.984, M22=.984, M12=.17, M21=-.17, SizingMethod='auto expand')"
],
'multiple filters (IE7 issue)': [
"a{filter:progid:DXImageTransform.Microsoft.Chroma(color=#919191) progid:DXImageTransform.Microsoft.Matrix(M11=0.984, M22=0.984, M12=0.17, M21=-0.17, SizingMethod='auto expand')}",
"a{filter:progid:DXImageTransform.Microsoft.Chroma(color=#919191) progid:DXImageTransform.Microsoft.Matrix(M11=.984, M22=.984, M12=.17, M21=-.17, SizingMethod='auto expand')}"
]
}),
'charsets': cssContext({
Expand Down

0 comments on commit c7d54e1

Please sign in to comment.