Skip to content

Commit

Permalink
update filter check to use CSS.supports when supported, gets around f…
Browse files Browse the repository at this point in the history
…alse negatives in firefox
  • Loading branch information
patrickkettner committed Mar 4, 2015
1 parent fff77ca commit 0c35733
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
13 changes: 11 additions & 2 deletions feature-detects/css/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,22 @@
}]
}
!*/
define(['Modernizr', 'createElement', 'prefixes'], function( Modernizr, createElement, prefixes ) {
define(['Modernizr', 'createElement', 'prefixes', 'test/css/supports'], function( Modernizr, createElement, prefixes ) {
// https://github.com/Modernizr/Modernizr/issues/615
// documentMode is needed for false positives in oldIE, please see issue above
Modernizr.addTest('cssfilters', function() {
var el = createElement('div');
el.style.cssText = prefixes.join('filter:blur(2px); ');
return !!el.style.length && ((document.documentMode === undefined || document.documentMode > 9));
if (Modernizr.supports) {
var supports = 'CSS' in window ?
window.CSS.supports('filter', 'url()') :
window.supportsCSS('filter', 'url()');

// older firefox only supports `url` filters;
return supports;
} else {
return !!el.style.length && ((document.documentMode === undefined || document.documentMode > 9));
}
});

});
10 changes: 5 additions & 5 deletions test/browser/integration/caniuse.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ window.caniusecb = function(caniuse) {
});
}

// caniuse counts `filter` opacity as partial support - we don't.
if (o.feature === 'opacity' && o.browser === 'IE' && o.version < 9) {
return;
}

// if caniuse gave us a 'partial', lets let it pass with a note.
if (o.caniuseResult.indexOf('a') === 0) {
return it(o.browser + o.version + ': Caniuse reported partial support for ' + o.ciufeature, function() {
Expand All @@ -213,11 +218,6 @@ window.caniusecb = function(caniuse) {
});
}

// caniuse counts `filter` opacity as partial support - we don't.
if (o.feature === 'opacity' && o.browser === 'IE' && o.version < 9) {
return;
}

// where we actually do most our assertions
it(o.browser + o.version + ': Caniuse result for ' + o.ciufeature + ' matches Modernizr\'s ' + (o.fp ? '*false positive*' : 'result') + ' for ' + o.feature, function() {
var modernizrResult = o.result instanceof Boolean ? o.result.valueOf() : !!o.result;
Expand Down

0 comments on commit 0c35733

Please sign in to comment.