From: Jakub Pawlowicz Date: Mon, 18 Apr 2011 07:36:55 +0000 (+0200) Subject: Fixed two issues with IE 7 filters. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=c7d54e16d4653d144ca96b8b60c361da832b265a;p=clean-css.git Fixed two issues with IE 7 filters. * Fixed issue with multiple IE filters (IE 7 couldn't handle them if shortened). * Fixed issue with restoring spaces in all IE filters. --- diff --git a/lib/clean.js b/lib/clean.js index 818cf960..dcc83e99 100644 --- a/lib/clean.js +++ b/lib/clean.js @@ -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 @@ -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 diff --git a/test/unit-test.js b/test/unit-test.js index fc28d8fb..681715d2 100644 --- a/test/unit-test.js +++ b/test/unit-test.js @@ -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({