Search code examples
browsersvggaussiansvg-filtersbrowser-feature-detection

Feature detecting support for svg filters


I need to feature detect whether a browser supports svg filters (feGaussianBlur, to be specific). How would I go about testing for this? Safari, which doesn't support the filter, silently ignores the filter.


Solution

  • You could probably also check the enums available on the interfaces, e.g:

    var supportsfilter = typeof SVGFEColorMatrixElement !== undefined && 
                         SVGFEColorMatrixElement.SVG_FECOLORMATRIX_TYPE_SATURATE==2;
    

    That way you won't have to construct new elements, as in https://stackoverflow.com/a/9767059/109374. I've not tested to see whether this works as expected in Safari.

    Update: Patch submitted to modernizr: https://github.com/Modernizr/Modernizr/pull/531